1use thiserror::Error;
2use web3::signing::RecoveryError;
3
4use crate::utils::Eip712Error;
5
6#[derive(Debug, Error)]
7pub enum BundlrError {
8 #[error("Invalid headers provided.")]
9 InvalidHeaders,
10
11 #[error("Invalid signer type used.")]
12 InvalidSignerType,
13
14 #[error("Invalid presence byte {0}")]
15 InvalidPresenceByte(String),
16
17 #[error("No bytes left.")]
18 NoBytesLeft,
19
20 #[error("Invalid tag encoding.")]
21 InvalidTagEncoding,
22
23 #[error("File system error: {0}")]
24 FsError(String),
25
26 #[error("Invalid signature.")]
27 InvalidSignature,
28
29 #[error("Invalid value for funding.")]
30 InvalidFundingValue,
31
32 #[error("Invalid amount, must be a integer bigger than zero")]
33 InvalidAmount,
34
35 #[error("Invalid wallet {0}")]
36 InvalidKey(String),
37
38 #[error("Invalid currency: {0}")]
39 InvalidCurrency(String),
40
41 #[error("Response failed with the following error: {0}")]
42 ResponseError(String),
43
44 #[error("Failed to sign message: {0}")]
45 SigningError(String),
46
47 #[error("Request error: {0}.")]
48 RequestError(String),
49
50 #[error("Tx not found")]
51 TxNotFound,
52
53 #[error("Tx status not confirmed")]
54 TxStatusNotConfirmed,
55
56 #[error("Chunk size out of allowed range: {0} - {0}")]
57 ChunkSizeOutOfRange(u64, u64),
58
59 #[error("Error posting chunk: {0}")]
60 PostChunkError(String),
61
62 #[error("No signature present")]
63 NoSignature,
64
65 #[error("Cannot convert file stream to known bytes. Try using another method")]
66 InvalidDataType,
67
68 #[error("Arweave Sdk error: {0}")]
69 ArweaveSdkError(arweave_rs::error::Error),
70
71 #[error("Currency error: {0}")]
72 CurrencyError(String),
73
74 #[error("Error reading/writting bytes: {0}")]
75 BytesError(String),
76
77 #[error("Error converting type: {0}")]
78 TypeParseError(String),
79
80 #[error("Parse error error: {0}")]
81 ParseError(String),
82
83 #[error("Upload error: {0}")]
84 UploadError(String),
85
86 #[error("Unknown: {0}")]
87 Unknown(String),
88
89 #[error("Unsupported: {0}")]
90 Unsupported(String),
91
92 #[error("ED25519 error: {0}")]
93 ED25519Error(ed25519_dalek::ed25519::Error),
94
95 #[error("Secp256k1 error: {0}")]
96 Secp256k1Error(secp256k1::Error),
97
98 #[error("Base64 error: {0}")]
99 Base64Error(String),
100
101 #[error("Io error: {0}")]
102 IoError(std::io::Error),
103
104 #[error("Builder error: {0}")]
105 BuilderError(BuilderError),
106
107 #[error("Eip712 error: {0}")]
108 Eip712Error(Eip712Error),
109
110 #[error("RecoveryError")]
111 RecoveryError(RecoveryError),
112}
113
114impl From<BuilderError> for BundlrError {
115 fn from(value: BuilderError) -> Self {
116 Self::BuilderError(value)
117 }
118}
119
120impl From<arweave_rs::error::Error> for BundlrError {
121 fn from(value: arweave_rs::error::Error) -> Self {
122 Self::ArweaveSdkError(value)
123 }
124}
125
126#[derive(Debug, Error)]
127pub enum BuilderError {
128 #[error("Bundlr Error {0}")]
129 BundlrError(String),
130
131 #[error("Missing field {0}")]
132 MissingField(String),
133
134 #[error("Fetch pub info error: {0}")]
135 FetchPubInfoError(String),
136
137 #[error("Arweave Sdk error: {0}")]
138 ArweaveSdkError(arweave_rs::error::Error),
139}
140
141impl From<arweave_rs::error::Error> for BuilderError {
142 fn from(value: arweave_rs::error::Error) -> Self {
143 Self::ArweaveSdkError(value)
144 }
145}
146
147impl From<BundlrError> for BuilderError {
148 fn from(value: BundlrError) -> Self {
149 Self::BundlrError(value.to_string())
150 }
151}