fireblocks_sdk/
error.rs

1use {
2    crate::{
3        apis::{
4            blockchains_assets_api::GetSupportedAssetsError,
5            transactions_api::{GetTransactionError, GetTransactionsError},
6            vaults_api::{
7                CreateVaultAccountAssetAddressError,
8                GetVaultAccountAssetAddressesPaginatedError,
9                GetVaultAccountError,
10            },
11        },
12        jwt,
13    },
14    thiserror::Error,
15    url::ParseError,
16};
17
18#[derive(Debug, Error)]
19pub enum ParamError {
20    #[error("Invalid params for {msg}")]
21    InvalidParams { msg: String },
22}
23
24#[derive(Debug, Error)]
25pub enum FireblocksError {
26    //#[error(transparent)]
27    // RequestError(#[from] crate::apis::Error<_>),
28    #[error(transparent)]
29    /// Thrown when Token fails
30    TokenError(#[from] jsonwebtoken::errors::Error),
31
32    #[error(transparent)]
33    /// Thrown when JWT signing fails
34    JwtError(#[from] jwt::JwtError),
35
36    #[error("Deserialization Error: {err}. Response: {text}")]
37    /// Serde JSON Error
38    SerdeJson {
39        request_id: String,
40        err: serde_json::Error,
41        text: String,
42    },
43
44    #[error(transparent)]
45    /// Thrown when submitting a POST/GET request fails
46    ReqwestError(#[from] reqwest::Error),
47
48    #[error(transparent)]
49    UrlError(#[from] ParseError),
50
51    #[error(transparent)]
52    QueryParamError(#[from] ParamError),
53
54    #[error("Internal Fireblocks Error. HTTP Code {code} {text} request_id:{request_id}")]
55    InternalError {
56        request_id: String,
57        path: String,
58        code: u16,
59        text: String,
60    },
61
62    #[error("{path} not found. request_id: {request_id}")]
63    NotFound { request_id: String, path: String },
64
65    #[error("Bad Request for {path} {text} request_id: {request_id}")]
66    BadRequest {
67        request_id: String,
68        path: String,
69        text: String,
70    },
71
72    #[error("Unauthorized for {path} {text} request_id: {request_id}")]
73    Unauthorized {
74        request_id: String,
75        path: String,
76        text: String,
77    },
78
79    #[error("Forbidden for {path} {text} request_id: {request_id}")]
80    Forbidden {
81        request_id: String,
82        path: String,
83        text: String,
84    },
85
86    #[error("Unknown Error HTTP Code: {code} request_id: {request_id}")]
87    Unknown {
88        request_id: String,
89        path: String,
90        code: u16,
91        text: String,
92    },
93
94    #[error("Invalid Request Error: {text}. Code: {code} request_id: {request_id}")]
95    InvalidRequest {
96        request_id: String,
97        code: u16,
98        text: String,
99    },
100
101    #[error(transparent)]
102    FetchTransactionsError(#[from] crate::apis::Error<GetTransactionsError>),
103
104    #[error(transparent)]
105    FetchVaultAccountError(#[from] crate::apis::Error<GetVaultAccountError>),
106
107    #[error(transparent)]
108    FetchAddressesError(#[from] crate::apis::Error<GetVaultAccountAssetAddressesPaginatedError>),
109
110    #[error(transparent)]
111    FetchTransactionError(#[from] crate::apis::Error<GetTransactionError>),
112
113    #[error(transparent)]
114    FetchCreateAssetError(#[from] crate::apis::Error<CreateVaultAccountAssetAddressError>),
115
116    #[error(transparent)]
117    FetchSupportedAssetsError(#[from] crate::apis::Error<GetSupportedAssetsError>),
118
119    #[error("failed to create vault asset {0}")]
120    FetchVaultAssetActivateCreateError(String),
121
122    #[error("failed to create vault {0}")]
123    FetchVaultCreateError(String),
124
125    #[error("failed to create wallet {0}")]
126    FetchWalletCreateError(String),
127
128    #[error("invalid wallet type {0}")]
129    InvalidWalletType(crate::WalletType),
130
131    #[error("failed fetch contract wallets: {0}")]
132    FetchWalletContractError(String),
133
134    #[error("failed fetch external wallets: {0}")]
135    FetchWalletExternalError(String),
136
137    #[error("failed fetch internal wallets: {0}")]
138    FetchWalletInternalError(String),
139
140    #[error("failed creating transaction: {0}")]
141    FetchCreateTransactionError(String),
142
143    #[error(transparent)]
144    UuidErr(#[from] uuid::Error),
145
146    #[error("failed fetching whitelisted wallet: {0}")]
147    FetchWalletError(String),
148
149    #[error("failed fetching vaults (paging): {0}")]
150    FetchVaultsPagedError(String),
151}