Skip to content

Commit

Permalink
Merge pull request #43 from kanko-travel/fix-sqlx-error-handling
Browse files Browse the repository at this point in the history
display more user friendly errors
  • Loading branch information
umran authored Oct 24, 2024
2 parents b831209 + 05702c3 commit ed350ef
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion model/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,14 @@ impl Error {

impl Display for Error {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_str(&format!("{:?}", self))
let msg = match self {
Self::BadRequest(d)
| Self::InternalError(d)
| Self::NotFound(d)
| Self::Unauthorized(d) => d.message.as_str(),
};

f.write_str(&format!("{}", msg))
}
}

Expand Down

0 comments on commit ed350ef

Please sign in to comment.