eigen_client_fireblocks/
error.rs

1use alloy::contract::Error as AlloyError;
2use jsonwebtoken::errors::Error;
3use reqwest::header::InvalidHeaderValue;
4use reqwest::Error as ReqwestError;
5use serde_json::Error as SerdeErr;
6use std::fmt;
7use thiserror::Error;
8
9/// Error returned by AvsRegistry
10#[derive(Debug, Error)]
11pub enum FireBlockError {
12    /// Could not sign the jwt payload
13    #[error("Failed to sign the jwt payload")]
14    JsonWebTokenError(Error),
15
16    /// Alloy Contract error
17    #[error("Alloy error{0}")]
18    AlloyContractError(#[from] AlloyError),
19
20    #[error("Other Error {0}")]
21    OtherError(String),
22
23    /// Reqwest error
24    #[error("Reqwest error {0}")]
25    ReqwestError(#[from] ReqwestError),
26
27    /// Invalid header value error
28    #[error("Invalid header value error {0}")]
29    InvalidHeaderValueError(#[from] InvalidHeaderValue),
30
31    /// Serde error
32    #[error("Serde json error {0}")]
33    SerdeError(#[from] SerdeErr),
34
35    /// Serde error
36    #[error("Chain Id not supported{0} . Create an issue at  https://github.com/Layr-Labs/eigensdk-rs/issues/new")]
37    AssetIDError(String),
38
39    /// Account not found in whitelisted accounts
40    #[error("Account not found in whitelisted accounts {0}")]
41    AccountNotFoundError(String),
42
43    /// Contract not found in whitelisted contract
44    #[error("Contract {0} not found in whitelisted contract")]
45    ContractNotFound(String),
46
47    /// Transaction failed or rejected or Cancelled or Blocked
48    #[error("Transaction Failed with  Status {0} , tx_id {1}")]
49    TransactionFailed(String, String),
50
51    /// To be broadcasted transactions
52    #[error("Transaction to be broadcasted with Status {0} , tx_id {1}")]
53    NotBroadcasted(String, String),
54
55    /// Receipt not available yet
56    #[error("Transaction not available yet with Status {0} , tx_id {1} ")]
57    ReceiptNotYetAvailable(String, String),
58
59    /// Transaction receipt not found
60    #[error("Transactin receipt not found with tx_id {0}")]
61    TransactionReceiptNotFound(String),
62}
63
64impl FireBlockError {
65    pub fn from<E: fmt::Display>(error: E) -> FireBlockError {
66        FireBlockError::OtherError(error.to_string())
67    }
68}
69
70impl From<&str> for FireBlockError {
71    fn from(err: &str) -> FireBlockError {
72        FireBlockError::OtherError(err.to_string())
73    }
74}