avail_rust_client/
error.rs1#[derive(thiserror::Error, Debug)]
2pub enum UserError {
3 #[error("{0}")]
4 Decoding(String),
5 #[error("{0}")]
6 ValidationFailed(String),
7 #[error("{0}")]
8 Other(String),
9}
10
11#[derive(thiserror::Error, Debug)]
12pub enum Error {
13 #[error("{0}")]
14 RpcError(avail_rust_core::rpc::Error),
15 #[error("{0}")]
16 User(UserError),
17 #[error("{0}")]
18 Other(String),
19}
20
21impl From<avail_rust_core::rpc::Error> for Error {
22 fn from(value: avail_rust_core::rpc::Error) -> Self {
23 Self::RpcError(value)
24 }
25}
26
27impl From<UserError> for Error {
28 fn from(value: UserError) -> Self {
29 Self::User(value)
30 }
31}
32
33impl From<&str> for Error {
34 fn from(value: &str) -> Self {
35 Self::Other(value.to_owned())
36 }
37}
38
39impl From<codec::Error> for Error {
40 fn from(value: codec::Error) -> Self {
41 Self::Other(value.to_string())
42 }
43}