mercadopago_sdk_rust/
errors.rs

1use serde::Deserialize;
2use thiserror::Error;
3
4#[derive(Error, Debug)]
5pub enum SDKError {
6    #[error("{0}")]
7    CredentialsError(String),
8
9    #[error(transparent)]
10    NetworkError(#[from] reqwest::Error),
11
12    #[error(transparent)]
13    ValidationError(#[from] ValidationError),
14
15    #[error("Something wrong happened.")]
16    GenericError,
17}
18
19#[derive(Error, Debug)]
20pub enum CreditCardError {}
21
22#[derive(Error, Debug)]
23pub enum ValidationError {
24    #[error("Item validation error: {0}")]
25    ItemError(String),
26}
27
28#[derive(Debug, Deserialize)]
29pub(crate) struct ApiError {
30    message: String,
31    status: i32,
32    error: String,
33    cause: Option<Vec<ErrorCause>>,
34}
35
36#[derive(Debug, Deserialize)]
37pub(crate) struct ErrorCause {
38    pub description: String,
39    pub code: String,
40}