summaryrefslogtreecommitdiff
path: root/libs/gui/LayerDebugInfo.cpp
diff options
context:
space:
mode:
author Jiyong Park <jiyong@google.com> 2023-08-04 11:36:41 +0900
committer Jiyong Park <jiyong@google.com> 2023-08-07 10:28:45 +0900
commite731c4900ba0bd9872da6645720ebb8963e2e54b (patch)
treeb93e694631482e13de5457dc18c4371a8e6a1f24 /libs/gui/LayerDebugInfo.cpp
parentada46f8b26c7486f5e25824d6142ebdd28c64105 (diff)
Add IntoBinderResult trait to simplify binder error handling
Before this change, returning binder::Result<T> was a bit cumbersome, and the integration with anyhow was not nice: ``` use anyhow::{Context, Result}; fn file_exists(name: &str) -> binder::Result<bool> { std::fs::metadata(name) .with_context("cannot find {}") .map_err(|e| { Status::new_service_specific_err_str( NOT_FOUND, Some("{:?}", e) ) })? } ``` With this change, above can be simplified as below: ``` use binder::IntoBinderResult; use anyhow::{Context, Result}; fn file_exists(name: &str) -> binder::Result<bool> { std::fs::metadata(name) .with_context("cannot find {}", name) .or_service_specific_exception(NOT_FOUND)? } ``` Bug: 294348831 Test: atest libbinder_rs-internal_test Change-Id: I4c669ac39c01f648f68ecf6db7e088edec034825
Diffstat (limited to 'libs/gui/LayerDebugInfo.cpp')
0 files changed, 0 insertions, 0 deletions