File tree Expand file tree Collapse file tree
src/controllers/api/comic Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -41,13 +41,18 @@ pub(crate) async fn remove_item(
4141 . map_err ( error:: ErrorInternalServerError ) ?
4242 . ok_or_else ( || error:: ErrorBadRequest ( anyhow ! ( "Item does not exist" ) ) ) ?;
4343
44- DatabaseOccurrence :: delete (
45- & mut * transaction,
46- request. item_id . into_inner ( ) ,
47- request. comic_id . into_inner ( ) ,
48- )
49- . await
50- . map_err ( error:: ErrorInternalServerError ) ?;
44+ let item_id = request. item_id . into_inner ( ) ;
45+ let comic_id = request. comic_id . into_inner ( ) ;
46+ let result = DatabaseOccurrence :: delete ( & mut * transaction, item_id, comic_id)
47+ . await
48+ . map_err ( error:: ErrorInternalServerError ) ?;
49+
50+ if result. rows_affected ( ) != 1 {
51+ return Err ( error:: ErrorNotFound ( format ! (
52+ "Could not delete item {} from comic {}; the item is not in the comic" ,
53+ item_id, comic_id
54+ ) ) ) ;
55+ }
5156
5257 LogEntry :: log_action (
5358 & mut * transaction,
You can’t perform that action at this time.
0 commit comments