summaryrefslogtreecommitdiff
path: root/neuralnetworks/1.0/utils/src/Device.cpp
diff options
context:
space:
mode:
authorMichael Butler <butlermichael@google.com>2020-11-22 20:25:34 -0800
committerMichael Butler <butlermichael@google.com>2020-12-07 22:58:39 +0000
commit61f508e018cff89c93a7e08b3dbde1eb6a2155df (patch)
treea2f8548dad0e6895417427fcfca614ccf2d857c5 /neuralnetworks/1.0/utils/src/Device.cpp
parentcb3498d91b3a666b852850781538f8f228a549db (diff)
Cleanup how transport errors are handled in NN utils
Prior to this change, whenever the NN utility code encountered a HIDL transport error, the error message would display the file and line number of the "handleTransportError" function itself. This change introduces a new macro "HANDLE_TRANSPORT_FAILURE" that handles the transport error in a similar way but now the error message displays the file and line number of where the macro is called. Bug: N/A Test: mma Change-Id: I35b34f8f5be52b7fcff0fbb58a37ab2b8c7dd8bb
Diffstat (limited to 'neuralnetworks/1.0/utils/src/Device.cpp')
-rw-r--r--neuralnetworks/1.0/utils/src/Device.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/neuralnetworks/1.0/utils/src/Device.cpp b/neuralnetworks/1.0/utils/src/Device.cpp
index ab3f5afb23..285c515c20 100644
--- a/neuralnetworks/1.0/utils/src/Device.cpp
+++ b/neuralnetworks/1.0/utils/src/Device.cpp
@@ -56,7 +56,7 @@ nn::GeneralResult<nn::Capabilities> initCapabilities(V1_0::IDevice* device) {
};
const auto ret = device->getCapabilities(cb);
- NN_TRY(hal::utils::handleTransportError(ret));
+ HANDLE_TRANSPORT_FAILURE(ret);
return result;
}
@@ -119,7 +119,8 @@ std::pair<uint32_t, uint32_t> Device::getNumberOfCacheFilesNeeded() const {
nn::GeneralResult<void> Device::wait() const {
const auto ret = kDevice->ping();
- return hal::utils::handleTransportError(ret);
+ HANDLE_TRANSPORT_FAILURE(ret);
+ return {};
}
nn::GeneralResult<std::vector<bool>> Device::getSupportedOperations(const nn::Model& model) const {
@@ -148,7 +149,7 @@ nn::GeneralResult<std::vector<bool>> Device::getSupportedOperations(const nn::Mo
};
const auto ret = kDevice->getSupportedOperations(hidlModel, cb);
- NN_TRY(hal::utils::handleTransportError(ret));
+ HANDLE_TRANSPORT_FAILURE(ret);
return result;
}
@@ -168,7 +169,7 @@ nn::GeneralResult<nn::SharedPreparedModel> Device::prepareModel(
const auto scoped = kDeathHandler.protectCallback(cb.get());
const auto ret = kDevice->prepareModel(hidlModel, cb);
- const auto status = NN_TRY(hal::utils::handleTransportError(ret));
+ const auto status = HANDLE_TRANSPORT_FAILURE(ret);
if (status != ErrorStatus::NONE) {
const auto canonical = nn::convert(status).value_or(nn::ErrorStatus::GENERAL_FAILURE);
return NN_ERROR(canonical) << "prepareModel failed with " << toString(status);