arweave_sdk_rs/
error.rs

1use std::string::FromUtf8Error;
2use url::ParseError;
3
4use thiserror::Error;
5
6#[allow(dead_code)]
7#[derive(Debug, Error)]
8pub enum Error {
9    #[error("Error getting oracle price: {0}")]
10    OracleGetPriceError(String),
11
12    #[error("Getting Arweave price from oracle: {0}")]
13    GetPriceError(String),
14
15    #[error("Status code not Ok")]
16    StatusCodeNotOk,
17
18    #[error("Unsigned transaction")]
19    UnsignedTransaction,
20
21    #[error("Invalid proof")]
22    InvalidProof,
23
24    #[error("Slice error")]
25    SliceError,
26
27    #[error("Invalid tag encoding.")]
28    InvalidValueForTx,
29
30    #[error("Invalid tag encoding.")]
31    InvalidTagEncoding,
32
33    #[error("Error getting network info: {0}")]
34    NetworkInfoError(String),
35
36    #[error("No bytes left.")]
37    NoBytesLeft,
38
39    #[error("Crypto error: {0}")]
40    CryptoError(String),
41
42    #[error("Error getting transaction info: {0}")]
43    TransactionInfoError(String),
44
45    #[error("Unknown Error.")]
46    UnknownError,
47
48    #[error("Error getting wallet: {0}")]
49    WalletError(String),
50
51    #[error("Wrong Id")]
52    TransactionWrongId,
53
54    #[error("Invalid signature")]
55    InvalidSignature,
56
57    #[error("Error posting chunk: {0}")]
58    PostChunkError(String),
59
60    #[error("Error signing: {0}")]
61    SigningError(String),
62
63    #[error("No field present: {0}")]
64    NoneError(String), //TODO: add option::NoneError implementation when released
65
66    #[error("Io Error")]
67    IoError(std::io::Error),
68
69    #[error("ParseIntError")]
70    ParseIntError(std::num::ParseIntError),
71
72    #[error("UrlParseError")]
73    UrlParseError(ParseError),
74
75    #[error("FromUtf8Error")]
76    FromUtf8Error(FromUtf8Error),
77
78    #[error("FromUtf8Error")]
79    JsonWebKeyError(jsonwebkey::Error),
80
81    #[error("KeyRejected")]
82    KeyParseError(String),
83
84    #[error("Reqwest error: {0}")]
85    ReqwestError(reqwest::Error),
86
87    #[error("Invalid Key")]
88    InvalidKeyError,
89
90    #[error("AddressError")]
91    AddressDecodeError,
92
93    #[error("MnemonicError")]
94    MnemonicDecodeError,
95
96    #[error("DecodeError")]
97    Base64DecodeError(base64::DecodeError),
98
99    #[error("SerdeJsonError")]
100    SerdeJsonError(serde_json::Error),
101
102    #[error("Number {0} is too large for an array of {1} bytes")]
103    NumberTooLargeError(usize, u64),
104
105    #[error("Arweave Gateway Error: status code {0}, message {1}")]
106    ArweaveGatewayError(String, String),
107}
108
109impl From<std::io::Error> for Error {
110    fn from(value: std::io::Error) -> Self {
111        Self::IoError(value)
112    }
113}