blob: 091fb15f5d181a006f7e833bab1de95c5c06d0be [file] [log] [blame]
Alan Stokes9ca14ca2021-10-20 14:25:57 +01001/*
2 * Copyright 2021 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17use android_system_composd::binder::Result as BinderResult;
18use anyhow::Result;
19use binder_common::new_binder_service_specific_error;
20use log::error;
21
22pub fn to_binder_result<T>(result: Result<T>) -> BinderResult<T> {
23 result.map_err(|e| {
24 let message = format!("{:?}", e);
25 error!("Returning binder error: {}", &message);
26 new_binder_service_specific_error(-1, message)
27 })
28}