summaryrefslogtreecommitdiff
path: root/libs/binder/Status.cpp
diff options
context:
space:
mode:
author Jeongik Cha <jeongik@google.com> 2019-03-18 14:38:33 +0900
committer Jeongik Cha <jeongik@google.com> 2019-03-19 10:23:02 +0900
commit89b3f8be8250ece9783d41dacf926377e641cd9f (patch)
tree4c604a702dffc933a2d99d3504cf271d3721f2fa /libs/binder/Status.cpp
parent91e66f9ba18f3d053859c58d6af97cdd4f79579b (diff)
Add exceptionToString method into binder::Status
String exceptionToString(int32_t exceptionCode) Add this method for logging purpose Test: m -j Bug: 127187108 Change-Id: I911c3a667ddbe39245e5c3bbbd09154b2902aad8
Diffstat (limited to 'libs/binder/Status.cpp')
-rw-r--r--libs/binder/Status.cpp22
1 files changed, 21 insertions, 1 deletions
diff --git a/libs/binder/Status.cpp b/libs/binder/Status.cpp
index a3f87557ab..8b33a56484 100644
--- a/libs/binder/Status.cpp
+++ b/libs/binder/Status.cpp
@@ -63,6 +63,26 @@ Status Status::fromStatusT(status_t status) {
return ret;
}
+std::string Status::exceptionToString(int32_t exceptionCode) {
+ switch (exceptionCode) {
+ #define EXCEPTION_TO_CASE(EXCEPTION) case EXCEPTION: return #EXCEPTION;
+ EXCEPTION_TO_CASE(EX_NONE)
+ EXCEPTION_TO_CASE(EX_SECURITY)
+ EXCEPTION_TO_CASE(EX_BAD_PARCELABLE)
+ EXCEPTION_TO_CASE(EX_ILLEGAL_ARGUMENT)
+ EXCEPTION_TO_CASE(EX_NULL_POINTER)
+ EXCEPTION_TO_CASE(EX_ILLEGAL_STATE)
+ EXCEPTION_TO_CASE(EX_NETWORK_MAIN_THREAD)
+ EXCEPTION_TO_CASE(EX_UNSUPPORTED_OPERATION)
+ EXCEPTION_TO_CASE(EX_SERVICE_SPECIFIC)
+ EXCEPTION_TO_CASE(EX_PARCELABLE)
+ EXCEPTION_TO_CASE(EX_HAS_REPLY_HEADER)
+ EXCEPTION_TO_CASE(EX_TRANSACTION_FAILED)
+ #undef EXCEPTION_TO_CASE
+ default: return std::to_string(exceptionCode);
+ }
+}
+
Status::Status(int32_t exceptionCode, int32_t errorCode)
: mException(exceptionCode),
mErrorCode(errorCode) {}
@@ -184,7 +204,7 @@ String8 Status::toString8() const {
if (mException == EX_NONE) {
ret.append("No error");
} else {
- ret.appendFormat("Status(%d): '", mException);
+ ret.appendFormat("Status(%d, %s): '", mException, exceptionToString(mException).c_str());
if (mException == EX_SERVICE_SPECIFIC ||
mException == EX_TRANSACTION_FAILED) {
ret.appendFormat("%d: ", mErrorCode);