Skip to main content

maib_client/mia/
error.rs

1pub type Result<T> = core::result::Result<T, Error>;
2
3#[derive(Debug)]
4pub enum Error {
5    /// Access token has expired or was not set.
6    Unauthorized,
7
8    /// An error occurred during a http request.
9    Http(String),
10
11    /// An error occrred during (de)serialization.
12    Json(String),
13
14    /// API server responded with errors.
15    Api(Vec<ApiError>),
16}
17
18#[derive(Debug, serde::Deserialize)]
19#[serde(rename_all = "camelCase")]
20pub struct ApiError {
21    error_code: String,
22    error_message: String,
23}
24
25impl ApiError {
26    pub fn code(&self) -> &str {
27        return &self.error_code;
28    }
29
30    pub fn message(&self) -> &str {
31        return &self.error_message;
32    }
33}