summaryrefslogtreecommitdiffstats
path: root/rust/src/errors.rs
diff options
context:
space:
mode:
Diffstat (limited to 'rust/src/errors.rs')
-rw-r--r--rust/src/errors.rs8
1 files changed, 5 insertions, 3 deletions
diff --git a/rust/src/errors.rs b/rust/src/errors.rs
index 08e79d51..cb53e6d1 100644
--- a/rust/src/errors.rs
+++ b/rust/src/errors.rs
@@ -85,6 +85,10 @@ pub enum FatcatError {
// Diesel constraint that we think is a user error
ConstraintViolation(String),
+ #[fail(display = "generic database 'not-found'")]
+ // This should generally get caught and handled
+ DatabaseRowNotFound,
+
// TODO: can these hold context instead of Inner?
#[fail(display = "unexpected database error: {}", _0)]
// other Diesel, R2d2 errors which we don't think are user errors (eg, connection failure)
@@ -112,9 +116,7 @@ impl Into<models::ErrorResponse> for FatcatError {
impl From<diesel::result::Error> for FatcatError {
fn from(inner: diesel::result::Error) -> FatcatError {
match inner {
- diesel::result::Error::NotFound => {
- FatcatError::NotFound("unknown".to_string(), "N/A".to_string())
- }
+ diesel::result::Error::NotFound => FatcatError::DatabaseRowNotFound,
diesel::result::Error::DatabaseError(_, _) => {
FatcatError::ConstraintViolation(inner.to_string())
}