diff --git a/src/main/java/de/zendric/app/xpensely_server/services/ExpenseListService.java b/src/main/java/de/zendric/app/xpensely_server/services/ExpenseListService.java index 284e89f..0f65b6e 100644 --- a/src/main/java/de/zendric/app/xpensely_server/services/ExpenseListService.java +++ b/src/main/java/de/zendric/app/xpensely_server/services/ExpenseListService.java @@ -117,7 +117,7 @@ public class ExpenseListService { public Expense updateExpense(Long expenseListId, Expense updatedExpense) { ExpenseList expenseList = repository.findById(expenseListId) - .orElseThrow(() -> new IllegalArgumentException("ExpenseList not found")); + .orElseThrow(() -> new ResourceNotFoundException("ExpenseList not found with id: " + expenseListId)); if (!expenseList.getExpenses().stream() .anyMatch(expense -> expense.getId().equals(updatedExpense.getId()))) { @@ -125,7 +125,7 @@ public class ExpenseListService { } Expense existingExpense = expenseRepository.findById(updatedExpense.getId()) - .orElseThrow(() -> new IllegalArgumentException("Expense not found")); + .orElseThrow(() -> new ResourceNotFoundException("Expense not found with id: " + updatedExpense.getId())); existingExpense.setTitle(updatedExpense.getTitle()); existingExpense.setAmount(updatedExpense.getAmount()); existingExpense.setPersonalUseAmount(updatedExpense.getPersonalUseAmount()); @@ -151,7 +151,7 @@ public class ExpenseListService { XpenselyCustomCategory category = customCategoryRepository.findById(categoryId) .orElseThrow(() -> new ResourceNotFoundException("Custom Category not found")); if (!category.getExpenseList().getId().equals(expenseListId)) { - throw new RuntimeException("Category does not belong to the specified Expense List"); + throw new IllegalArgumentException("Category does not belong to the specified Expense List"); } customCategoryRepository.delete(category); }