Skip to main content

crypdefi_bot_sdk/
error.rs

1use std::env;
2
3/// Possible errors that can occur inside the library
4#[derive(Debug, thiserror::Error)]
5pub enum BotSdkError {
6    #[error("Error in pkcs8 certificates")]
7    Pkcs8Error(#[from] p256::pkcs8::Error),
8
9    #[error("Something happened while doing der encoding and decoding")]
10    DerError(#[from] p256::pkcs8::der::Error),
11
12    #[error("Something happened during ecdsa signature operation")]
13    EcdsaError(#[from] p256::ecdsa::Error),
14
15    #[error("Error of during rest request")]
16    RequestError(#[from] reqwest::Error),
17
18    #[error("Error during json parsing")]
19    SerdeJsonError(#[from] serde_json::Error),
20
21    #[error("Error during environment variable checking")]
22    VarError(#[from] env::VarError),
23
24    #[error("There is no access token available")]
25    NoAccessToken,
26
27    #[error("There is no refresh token available")]
28    NoRefreshToken,
29
30    #[error("Invalid user id")]
31    InvalidUserId,
32
33    #[error("Id is not a user id. User Id starts with 'us'")]
34    IdNotUserId,
35
36    #[error("Could not decode hex error")]
37    HxError(#[from] const_hex::FromHexError),
38
39    #[error("Secp256k1 ecdsa error")]
40    Secp256k1Error(#[from] secp256k1::Error),
41
42    #[error("Something happened that required a custom error: {0}")]
43    Custom(String),
44}