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