Skip to content

Commit

Permalink
feat: use thiserror for StoreTokenError
Browse files Browse the repository at this point in the history
  • Loading branch information
migueloller committed Feb 8, 2024
1 parent d35dc5a commit b11a24d
Showing 1 changed file with 2 additions and 16 deletions.
18 changes: 2 additions & 16 deletions src/routes/subscriptions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,8 @@ pub async fn store_token(
Ok(())
}

#[derive(thiserror::Error)]
#[error("A database error was encountered while trying to store a subscription token.")]
pub struct StoreTokenError(sqlx::Error);

impl std::fmt::Debug for StoreTokenError {
Expand All @@ -162,22 +164,6 @@ impl std::fmt::Debug for StoreTokenError {
}
}

impl std::fmt::Display for StoreTokenError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(
f,
"A database error was encountered while \
trying to store a subscription token."
)
}
}

impl std::error::Error for StoreTokenError {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
Some(&self.0)
}
}

fn error_chain_fmt(
e: &impl std::error::Error,
f: &mut std::fmt::Formatter<'_>,
Expand Down

0 comments on commit b11a24d

Please sign in to comment.