1 // Copyright 2022, The Android Open Source Project
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //     http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 //! Defines errors used by the crate
16 use uwb_core::error::Error as UwbError;
17 
18 /// Combined error enum representing either a JNI error, Parse error or UWB service error
19 #[derive(Debug, thiserror::Error)]
20 pub enum Error {
21     /// JNI error returned from calls to the JNI crate
22     #[error("JNI Error: {0}")]
23     Jni(#[from] jni::errors::Error),
24     /// Parse error returned when failing to convert primitives or objects
25     #[error("Parse error: {0}")]
26     Parse(String),
27     /// Error returned from UWB service
28     #[error("Uwb service error: {0}")]
29     Uwb(#[from] UwbError),
30 }
31 
32 pub type Result<T> = std::result::Result<T, Error>;
33