feat: D1 — Shopping list (Issue #30) #43
@@ -0,0 +1,7 @@
|
||||
package com.recipeapp.common;
|
||||
|
||||
public class ForbiddenException extends RuntimeException {
|
||||
public ForbiddenException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
||||
@@ -32,6 +32,12 @@ public class GlobalExceptionHandler {
|
||||
.body(ApiError.of("CONFLICT", ex.getMessage()));
|
||||
}
|
||||
|
||||
@ExceptionHandler(ForbiddenException.class)
|
||||
public ResponseEntity<ApiError> handleForbidden(ForbiddenException ex) {
|
||||
return ResponseEntity.status(HttpStatus.FORBIDDEN)
|
||||
.body(ApiError.of("FORBIDDEN", ex.getMessage()));
|
||||
}
|
||||
|
||||
@ExceptionHandler(ValidationException.class)
|
||||
public ResponseEntity<ApiError> handleBusinessValidation(ValidationException ex) {
|
||||
return ResponseEntity.status(HttpStatus.UNPROCESSABLE_ENTITY)
|
||||
|
||||
Reference in New Issue
Block a user