1use reqwest::header::ToStrError;
2use thiserror::Error;
3
4#[derive(Debug, Error)]
6pub enum SdkError {
7 #[error("I/O error: {0}")]
9 Io(#[from] std::io::Error),
10 #[error("Reqwest error: {0}")]
12 Reqwest(#[from] reqwest::Error),
13 #[error("Http header to string error: {0}")]
15 HeaderToStr(#[from] ToStrError),
16 #[error("Serde error: {0}")]
18 Json(#[from] serde_json::Error),
19 #[error("Hex error: {0}")]
21 Hex(#[from] hex::FromHexError),
22 #[error("Signature error: {0}")]
24 EcdsaSignature(#[from] ecdsa::signature::Error),
25 #[error("Bls error: {0}")]
27 Bls(#[from] lit_node_core::lit_rust_crypto::blsful::BlsError),
28 #[error("String parse error: {0}")]
30 Parse(String),
31 #[error("Build request error: {0}")]
33 Build(String),
34 #[error("Decryption error: {0}")]
36 Decryption(String),
37 #[error("The Attestation report data doesn't match the provided data")]
39 Attestation,
40 #[error("Invalid type conversion: {0}")]
42 InvalidType(String),
43 #[error("An error occurred while combining signatures: {0}")]
45 SignatureCombine(String),
46 #[error("Signature does not verify with the given message and public key")]
48 SignatureVerify,
49 #[error("Admin endpoint error: {0}")]
51 Admin(String),
52}
53
54pub type SdkResult<T> = Result<T, SdkError>;
56
57impl From<lit_node_core::Error> for SdkError {
58 fn from(e: lit_node_core::Error) -> Self {
59 match e {
60 lit_node_core::Error::Parse(e) => SdkError::Parse(e),
61 lit_node_core::Error::InvalidType(e) => SdkError::InvalidType(e),
62 }
63 }
64}