Fixed clippy warnings.
This commit is contained in:
+3
-3
@@ -8,7 +8,7 @@ use crate::routes::dtos::expense::RecurringExpenseConversionError;
|
||||
#[derive(Debug)]
|
||||
pub enum AppError {
|
||||
Database(sqlx::Error),
|
||||
InvalidRecurringExpense(RecurringExpenseConversionError),
|
||||
RecurringExpense(RecurringExpenseConversionError),
|
||||
}
|
||||
|
||||
impl From<sqlx::Error> for AppError {
|
||||
@@ -19,7 +19,7 @@ impl From<sqlx::Error> for AppError {
|
||||
|
||||
impl From<RecurringExpenseConversionError> for AppError {
|
||||
fn from(error: RecurringExpenseConversionError) -> Self {
|
||||
Self::InvalidRecurringExpense(error)
|
||||
Self::RecurringExpense(error)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ impl IntoResponse for AppError {
|
||||
fn into_response(self) -> Response {
|
||||
match self {
|
||||
Self::Database(error) => tracing::error!(%error, "Database query failed"),
|
||||
Self::InvalidRecurringExpense(error) => {
|
||||
Self::RecurringExpense(error) => {
|
||||
tracing::error!(%error, "Invalid recurring expense data")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,9 +46,9 @@ pub enum WeekendAdjustment {
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum RecurringExpenseConversionError {
|
||||
InvalidRecurrenceEvery(i32),
|
||||
InvalidRecurrenceUnit(String),
|
||||
InvalidWeekendAdjustment(String),
|
||||
RecurrenceEvery(i32),
|
||||
RecurrenceUnit(String),
|
||||
WeekendAdjustment(String),
|
||||
}
|
||||
|
||||
impl From<RecurringExpense> for Expense {
|
||||
@@ -60,13 +60,13 @@ impl From<RecurringExpense> for Expense {
|
||||
impl std::fmt::Display for RecurringExpenseConversionError {
|
||||
fn fmt(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
match self {
|
||||
Self::InvalidRecurrenceEvery(value) => {
|
||||
Self::RecurrenceEvery(value) => {
|
||||
write!(formatter, "invalid recurrence_every value: {value}")
|
||||
}
|
||||
Self::InvalidRecurrenceUnit(value) => {
|
||||
Self::RecurrenceUnit(value) => {
|
||||
write!(formatter, "invalid recurrence_unit value: {value}")
|
||||
}
|
||||
Self::InvalidWeekendAdjustment(value) => {
|
||||
Self::WeekendAdjustment(value) => {
|
||||
write!(formatter, "invalid weekend_adjustment value: {value}")
|
||||
}
|
||||
}
|
||||
@@ -87,7 +87,7 @@ impl TryFrom<RecurringExpenseRow> for RecurringExpense {
|
||||
end: row.ends_at,
|
||||
recurrence: Recurrence {
|
||||
every: row.recurrence_every.try_into().map_err(|_| {
|
||||
RecurringExpenseConversionError::InvalidRecurrenceEvery(row.recurrence_every)
|
||||
RecurringExpenseConversionError::RecurrenceEvery(row.recurrence_every)
|
||||
})?,
|
||||
unit: RecurrenceUnit::try_from(row.recurrence_unit)?,
|
||||
weekend_adjustment: match row.weekend_adjustment {
|
||||
@@ -108,9 +108,7 @@ impl TryFrom<String> for RecurrenceUnit {
|
||||
"week" => Ok(Self::Week),
|
||||
"month" => Ok(Self::Month),
|
||||
"year" => Ok(Self::Year),
|
||||
_ => Err(RecurringExpenseConversionError::InvalidRecurrenceUnit(
|
||||
value,
|
||||
)),
|
||||
_ => Err(RecurringExpenseConversionError::RecurrenceUnit(value)),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -122,9 +120,7 @@ impl TryFrom<String> for WeekendAdjustment {
|
||||
match value.as_str() {
|
||||
"previous_business_day" => Ok(Self::PreviousBusinessDay),
|
||||
"next_business_day" => Ok(Self::NextBusinessDay),
|
||||
_ => Err(RecurringExpenseConversionError::InvalidWeekendAdjustment(
|
||||
value,
|
||||
)),
|
||||
_ => Err(RecurringExpenseConversionError::WeekendAdjustment(value)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user