addItem 404 exception hinzugefügt

This commit is contained in:
Technoir committed 2026-10-11 13:44:14 +02:00
1 parent 7c81870665
commit a467d3f4a7
1 file changed
+3 -2
@@ -38,11 +38,12 @@ public class ShoppingItemController {
String amount = newItem.itemAmount();
ShoppingCategory c;
if(newItem.categoryID() != null){
c = shoppingCategoryRepository.findById(newItem.categoryID()).orElseThrow();
c = shoppingCategoryRepository.findById(newItem.categoryID()).orElseThrow(() -> new ResourceNotFoundException("categoryID", newItem.categoryID()));
}else{
c = null;
}
ShoppingList list = shoppingListRepository.findById(newItem.listID()).orElseThrow();
ShoppingList list = shoppingListRepository.findById(newItem.listID()).orElseThrow(() -> new ResourceNotFoundException("listID", newItem.listID()));
ShoppingItem item = new ShoppingItem(name, amount, false, c, list);
shoppingItemRepository.save(item);