pub enum CurrencyError {
Network(Error),
Json(Error),
Api {
message: String,
},
InvalidCurrency {
code: String,
},
InvalidAmount {
amount: f64,
},
Configuration {
message: String,
},
Conversion {
message: String,
},
}
Expand description
Custom error type for currency converter operations
Variants§
Network(Error)
Network-related errors (timeouts, connection failures)
Json(Error)
JSON parsing errors
Api
API-specific errors (invalid currency codes, rate limits)
InvalidCurrency
Invalid currency code
InvalidAmount
Invalid amount (negative, NaN, etc.)
Configuration
Configuration errors (missing API key, invalid settings)
Conversion
Generic conversion errors
Implementations§
Source§impl CurrencyError
impl CurrencyError
Sourcepub fn configuration<S: Into<String>>(message: S) -> Self
pub fn configuration<S: Into<String>>(message: S) -> Self
Create a new configuration error
Sourcepub fn conversion<S: Into<String>>(message: S) -> Self
pub fn conversion<S: Into<String>>(message: S) -> Self
Create a new conversion error
Sourcepub fn invalid_currency<S: Into<String>>(code: S) -> Self
pub fn invalid_currency<S: Into<String>>(code: S) -> Self
Create an invalid currency error
Sourcepub fn invalid_amount(amount: f64) -> Self
pub fn invalid_amount(amount: f64) -> Self
Create an invalid amount error
Trait Implementations§
Source§impl Debug for CurrencyError
impl Debug for CurrencyError
Source§impl Display for CurrencyError
impl Display for CurrencyError
Source§impl Error for CurrencyError
impl Error for CurrencyError
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0: use the Display impl or to_string()
Source§impl From<Error> for CurrencyError
impl From<Error> for CurrencyError
Auto Trait Implementations§
impl Freeze for CurrencyError
impl !RefUnwindSafe for CurrencyError
impl Send for CurrencyError
impl Sync for CurrencyError
impl Unpin for CurrencyError
impl !UnwindSafe for CurrencyError
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
Mutably borrows from an owned value. Read more