Implemented thiserror.
This commit is contained in:
@@ -32,23 +32,13 @@ impl TryFrom<TransactionRow> for TransactionResponse {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
pub enum TransactionConversionError {
|
||||
#[error("invalid amount_cents value: {0}")]
|
||||
AmountCents(i64),
|
||||
Direction(DirectionConversionError),
|
||||
}
|
||||
|
||||
impl std::error::Error for TransactionConversionError {}
|
||||
|
||||
impl std::fmt::Display for TransactionConversionError {
|
||||
fn fmt(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
match self {
|
||||
Self::AmountCents(value) => {
|
||||
write!(formatter, "invalid amount_cents value: {value}")
|
||||
}
|
||||
Self::Direction(error) => error.fmt(formatter),
|
||||
}
|
||||
}
|
||||
#[error(transparent)]
|
||||
Direction(#[from] DirectionConversionError),
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
Reference in New Issue
Block a user