deleteItem 404 exception hinzugefügt

This commit is contained in:
Technoir committed 2026-10-11 13:45:12 +02:00
1 parent 1e1b8d0ec5
commit 71fd6ee420
1 file changed
+1 -3
@@ -66,9 +66,7 @@ public class ShoppingItemController {
@DeleteMapping("/api/items/{itemID}")
public ResponseEntity<Void> deleteItem(@PathVariable UUID itemID){
if(!shoppingItemRepository.existsById(itemID)){
return ResponseEntity.notFound().build();
}
shoppingItemRepository.findById(itemID).orElseThrow(() ->new ResourceNotFoundException("itemID",itemID));
shoppingItemRepository.deleteById(itemID);
return ResponseEntity.noContent().build();
}