Expound on HIDL Return errors.
Add 'onValueRetrieval' error which explicitly talks about the error
being while retrieving a value (since 'assertOk' was publically
exposed, it no longer makes sense to have a specific error).
assertOk is now also used in ~return_status and contains even more
information about how to interpret the error.
Bug: many
Test: TH
Change-Id: I80a7ec2ae42b7980a0a84fc760d5b27b17f293db
diff --git a/base/Status.cpp b/base/Status.cpp
index 90474a0..08631cc 100644
--- a/base/Status.cpp
+++ b/base/Status.cpp
@@ -149,19 +149,28 @@
}
namespace details {
- void return_status::assertOk() const {
+ void return_status::onValueRetrieval() const {
if (!isOk()) {
LOG(FATAL) << "Attempted to retrieve value from failed HIDL call: " << description();
}
}
+ void return_status::assertOk() const {
+ if (!isOk()) {
+ LOG(FATAL) << "Failed HIDL return status not checked. Usually this happens because of "
+ "a transport error (error parceling, binder driver, or from unparceling)"
+ ". If you see this in code calling into \"Bn\" classes in for a HAL "
+ "server process, then it is likely that the code there is returning "
+ "transport errors there (as opposed to errors defined within its "
+ "protocol). Error is: " << description();
+ }
+ }
+
return_status::~return_status() {
// mCheckedStatus must be checked before isOk since isOk modifies mCheckedStatus
if (mCheckedStatus) return;
- if (!isOk()) {
- LOG(FATAL) << "Failed HIDL return status not checked: " << description();
- }
+ assertOk();
if (gReturnRestriction == HidlReturnRestriction::NONE) {
return;
@@ -176,9 +185,10 @@
}
return_status& return_status::operator=(return_status&& other) noexcept {
- if (!mCheckedStatus && !isOk()) {
- LOG(FATAL) << "Failed HIDL return status not checked: " << description();
+ if (!mCheckedStatus) {
+ assertOk();
}
+
std::swap(mStatus, other.mStatus);
std::swap(mCheckedStatus, other.mCheckedStatus);
return *this;