1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
use serde::Deserialize;
use thiserror::Error;

#[derive(Error, Debug)]
pub enum SDKError {
    #[error("{0}")]
    CredentialsError(String),

    #[error(transparent)]
    NetworkError(#[from] reqwest::Error),

    #[error(transparent)]
    ValidationError(#[from] ValidationError),

    #[error("Something wrong happened.")]
    GenericError,
}

#[derive(Error, Debug)]
pub enum CreditCardError {}

#[derive(Error, Debug)]
pub enum ValidationError {
    #[error("Item validation error: {0}")]
    ItemError(String),
}

#[derive(Debug, Deserialize)]
pub(crate) struct ApiError {
    message: String,
    status: i32,
    error: String,
    cause: Option<Vec<ErrorCause>>,
}

#[derive(Debug, Deserialize)]
pub(crate) struct ErrorCause {
    pub description: String,
    pub code: String,
}