pub enum Error {
Show 22 variants
Json(Error),
Api {
status_code: u16,
error_code: String,
message: String,
},
HttpTransport {
message: String,
status_code: Option<u16>,
},
RequestTimeout {
endpoint: String,
timeout_ms: u64,
},
Connection(String),
DnsResolution(String),
ResponseDeserialization {
format: String,
error: String,
response: String,
},
Authentication(String),
Authorization(String),
RateLimitExceeded {
retry_after_seconds: Option<u64>,
},
InvalidParameter {
parameter: String,
message: String,
},
ResourceNotFound {
resource_type: String,
identifier: String,
},
BusinessLogic {
operation: String,
reason: String,
},
Crypto(CryptoError),
VerificationError(String),
Config(ConfigError),
Url(ParseError),
Hex(FromHexError),
Address(String),
ArrayConversion {
expected: usize,
actual: usize,
},
Validation {
field: String,
message: String,
},
Custom(String),
}Expand description
Main error type for the OneMoney SDK.
Variants§
Json(Error)
JSON serialization/deserialization error.
Api
API error returned by the server.
HttpTransport
HTTP transport error with optional status code.
RequestTimeout
Request timeout error.
Connection(String)
Connection error.
DnsResolution(String)
DNS resolution error.
ResponseDeserialization
Response deserialization error.
Authentication(String)
Authentication error.
Authorization(String)
Authorization error.
RateLimitExceeded
Rate limit exceeded.
InvalidParameter
Invalid request parameter.
ResourceNotFound
Resource not found.
BusinessLogic
Business logic error.
Crypto(CryptoError)
Cryptographic operation errors.
VerificationError(String)
Signature verification failed.
Config(ConfigError)
Client configuration errors.
Url(ParseError)
URL parsing error.
Hex(FromHexError)
Hex decoding error.
Address(String)
Address parsing error.
ArrayConversion
Array conversion error.
Validation
Validation error for input parameters.
Custom(String)
Generic error with custom message.
Implementations§
Source§impl Error
impl Error
Sourcepub fn api(status_code: u16, error_code: String, message: String) -> Self
pub fn api(status_code: u16, error_code: String, message: String) -> Self
Create a new API error.
Sourcepub fn array_conversion(expected: usize, actual: usize) -> Self
pub fn array_conversion(expected: usize, actual: usize) -> Self
Create an array conversion error.
Sourcepub fn validation<T: Into<String>, U: Into<String>>(
field: T,
message: U,
) -> Self
pub fn validation<T: Into<String>, U: Into<String>>( field: T, message: U, ) -> Self
Create a validation error.
Sourcepub fn verification_error<T: Into<String>>(msg: T) -> Self
pub fn verification_error<T: Into<String>>(msg: T) -> Self
Create a verification error.
Sourcepub fn is_api_error(&self) -> bool
pub fn is_api_error(&self) -> bool
Check if this is an API error.
Sourcepub fn is_config_error(&self) -> bool
pub fn is_config_error(&self) -> bool
Check if this is a configuration error.
Sourcepub fn is_crypto_error(&self) -> bool
pub fn is_crypto_error(&self) -> bool
Check if this is a cryptographic error.
Sourcepub fn status_code(&self) -> Option<u16>
pub fn status_code(&self) -> Option<u16>
Get the status code if this is an API error.
Sourcepub fn error_code(&self) -> Option<&str>
pub fn error_code(&self) -> Option<&str>
Get the error code if this is an API error.
Sourcepub fn http_transport<T: Into<String>>(
message: T,
status_code: Option<u16>,
) -> Self
pub fn http_transport<T: Into<String>>( message: T, status_code: Option<u16>, ) -> Self
Create an HTTP transport error.
Sourcepub fn request_timeout<T: Into<String>>(endpoint: T, timeout_ms: u64) -> Self
pub fn request_timeout<T: Into<String>>(endpoint: T, timeout_ms: u64) -> Self
Create a request timeout error.
Sourcepub fn connection<T: Into<String>>(message: T) -> Self
pub fn connection<T: Into<String>>(message: T) -> Self
Create a connection error.
Sourcepub fn dns_resolution<T: Into<String>>(message: T) -> Self
pub fn dns_resolution<T: Into<String>>(message: T) -> Self
Create a DNS resolution error.
Sourcepub fn response_deserialization<A: Into<String>, B: Into<String>, C: Into<String>>(
format: A,
error: B,
response: C,
) -> Self
pub fn response_deserialization<A: Into<String>, B: Into<String>, C: Into<String>>( format: A, error: B, response: C, ) -> Self
Create a response deserialization error.
Sourcepub fn authentication<T: Into<String>>(message: T) -> Self
pub fn authentication<T: Into<String>>(message: T) -> Self
Create an authentication error.
Create an authorization error.
Sourcepub fn rate_limit_exceeded(retry_after_seconds: Option<u64>) -> Self
pub fn rate_limit_exceeded(retry_after_seconds: Option<u64>) -> Self
Create a rate limit exceeded error.
Sourcepub fn invalid_parameter<A: Into<String>, B: Into<String>>(
parameter: A,
message: B,
) -> Self
pub fn invalid_parameter<A: Into<String>, B: Into<String>>( parameter: A, message: B, ) -> Self
Create an invalid parameter error.
Trait Implementations§
Source§impl Error for Error
impl Error for Error
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
Source§impl From<ConfigError> for Error
impl From<ConfigError> for Error
Source§fn from(source: ConfigError) -> Self
fn from(source: ConfigError) -> Self
Source§impl From<CryptoError> for Error
impl From<CryptoError> for Error
Source§fn from(source: CryptoError) -> Self
fn from(source: CryptoError) -> Self
Source§impl From<FromHexError> for Error
impl From<FromHexError> for Error
Source§fn from(source: FromHexError) -> Self
fn from(source: FromHexError) -> Self
Source§impl From<ParseError> for Error
impl From<ParseError> for Error
Source§fn from(source: ParseError) -> Self
fn from(source: ParseError) -> Self
Source§impl From<TryFromSliceError> for Error
impl From<TryFromSliceError> for Error
Source§fn from(_err: TryFromSliceError) -> Self
fn from(_err: TryFromSliceError) -> Self
Auto Trait Implementations§
impl Freeze for Error
impl !RefUnwindSafe for Error
impl Send for Error
impl Sync for Error
impl Unpin for Error
impl !UnwindSafe for Error
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.