This commit is contained in:
2023-08-29 21:34:00 +02:00
parent be9be4c9da
commit 6e8873f1b9
6 changed files with 22 additions and 24 deletions

View File

@@ -118,16 +118,16 @@ impl From<sqlx::Error> for Error {
match &*code {
// SQLITE_CONSTRAINT_FOREIGNKEY
"787" => Error::Query(QueryError::ReferenceNotFound {
description: format!("foreign key reference not found"),
description: "foreign key reference not found".to_string(),
}),
// SQLITE_CONSTRAINT_UNIQUE
"2067" => Error::Query(QueryError::Duplicate {
description: format!("item with unique constraint already exists",),
description: "item with unique constraint already exists".to_string(),
}),
_ => Error::Database(DatabaseError::Sql {
description: format!(
"got error with unknown code: {}",
sqlite_error.to_string()
sqlite_error
),
}),
}
@@ -135,13 +135,13 @@ impl From<sqlx::Error> for Error {
Error::Database(DatabaseError::Sql {
description: format!(
"got error without code: {}",
sqlite_error.to_string()
sqlite_error
),
})
}
}
_ => Error::Database(DatabaseError::Sql {
description: format!("got unknown error: {}", value.to_string()),
description: format!("got unknown error: {}", value),
}),
}
}

View File

@@ -29,7 +29,7 @@ impl Inventory {
.collect::<Result<Vec<Category>, Error>>()?;
for category in &mut categories {
category.populate_items(&ctx, &pool).await?;
category.populate_items(ctx, pool).await?;
}
Ok(Self { categories })