reclaim_rust_sdk/utils/
errors.rs1use thiserror::Error;
2use url::ParseError as UrlParseError;
3use serde_json::Error as JsonError;
4use hex::FromHexError;
5use rustc_hex::FromHexError as RustcFromHexError;
6
7#[derive(Error, Debug)]
8#[error("Operation timed out: {0}")]
9pub struct TimeoutError(pub String);
10
11#[derive(Error, Debug)]
12#[error("Proof verification failed: {0}")]
13pub struct ProofNotVerifiedError(pub String);
14
15#[derive(Error, Debug)]
16#[error("Session not started: {0}")]
17pub struct SessionNotStartedError(pub String);
18
19#[derive(Error, Debug)]
20#[error("Provider not found: {0}")]
21pub struct ProviderNotFoundError(pub String);
22
23#[derive(Error, Debug)]
24#[error("Failed to build proof request: {0}")]
25pub struct BuildProofRequestError(pub String);
26
27#[derive(Error, Debug)]
28#[error("Failed to generate signature: {0}")]
29pub struct SignatureGeneratingError(pub String);
30
31#[derive(Error, Debug)]
32#[error("Signature not found: {0}")]
33pub struct SignatureNotFoundError(pub String);
34
35#[derive(Error, Debug)]
36#[error("Invalid signature: {0}")]
37pub struct InvalidSignatureError(pub String);
38
39#[derive(Error, Debug)]
40#[error("Failed to update session: {0}")]
41pub struct UpdateSessionError(pub String);
42
43#[derive(Error, Debug)]
44#[error("Failed to initialize session: {0}")]
45pub struct InitSessionError(pub String);
46
47#[derive(Error, Debug)]
48#[error("Provider failed: {0}")]
49pub struct ProviderFailedError(pub String);
50
51#[derive(Error, Debug)]
52#[error("Invalid parameter: {0}")]
53pub struct InvalidParamError(pub String);
54
55#[derive(Error, Debug)]
56#[error("Application error: {0}")]
57pub struct ApplicationError(pub String);
58
59#[derive(Error, Debug)]
60#[error("Initialization error: {0}")]
61pub struct InitError(pub String);
62
63#[derive(Error, Debug)]
64#[error("Available parameters error: {0}")]
65pub struct AvailableParamsError(pub String);
66
67#[derive(Error, Debug)]
68#[error("Backend server error: {0}")]
69pub struct BackendServerError(pub String);
70
71#[derive(Error, Debug)]
72#[error("Failed to get status URL: {0}")]
73pub struct GetStatusUrlError(pub String);
74
75#[derive(Error, Debug)]
76#[error("No provider parameters: {0}")]
77pub struct NoProviderParamsError(pub String);
78
79#[derive(Error, Debug)]
80#[error("Failed to set parameters: {0}")]
81pub struct SetParamsError(pub String);
82
83#[derive(Error, Debug)]
84#[error("Failed to add context: {0}")]
85pub struct AddContextError(pub String);
86
87#[derive(Error, Debug)]
88#[error("Failed to set signature: {0}")]
89pub struct SetSignatureError(pub String);
90
91#[derive(Error, Debug)]
92#[error("Failed to get app callback URL: {0}")]
93pub struct GetAppCallbackUrlError(pub String);
94
95#[derive(Error, Debug)]
96#[error("Failed to get request URL: {0}")]
97pub struct GetRequestUrlError(pub String);
98
99#[derive(Error, Debug)]
100#[error("Status URL error: {0}")]
101pub struct StatusUrlError(pub String);
102
103#[derive(Error, Debug)]
104#[error("Proof submission failed: {0}")]
105pub struct ProofSubmissionFailedError(pub String);
106
107#[derive(Error, Debug)]
109#[error("Beacon not found: {0}")]
110pub struct BeaconNotFoundError(pub String);
111
112
113#[derive(Error, Debug)]
115#[error("Failed to get Beacon State: {0}")]
116pub struct GetBeaconStateError(pub String);
117
118
119#[derive(Error, Debug)]
121#[error("Failed to close Beacon: {0}")]
122pub struct CloseBeaconError(pub String);
123
124#[derive(Error, Debug)]
126#[error("Unsupported Chain: {0}")]
127pub struct UnsupportedChainError(pub String);
128
129impl From<UrlParseError> for ProofNotVerifiedError {
130 fn from(err: UrlParseError) -> Self {
131 ProofNotVerifiedError(err.to_string())
132 }
133}
134
135impl From<JsonError> for ProofNotVerifiedError {
136 fn from(err: JsonError) -> Self {
137 ProofNotVerifiedError(err.to_string())
138 }
139}
140
141impl From<FromHexError> for ProofNotVerifiedError {
142 fn from(err: FromHexError) -> Self {
143 ProofNotVerifiedError(err.to_string())
144 }
145}
146
147impl From<RustcFromHexError> for ProofNotVerifiedError {
148 fn from(err: RustcFromHexError) -> Self {
149 ProofNotVerifiedError(err.to_string())
150 }
151}