diff --git a/src/main/java/com/litoralregas/openvpn/common/ApiExceptionHandler.java b/src/main/java/com/litoralregas/openvpn/common/ApiExceptionHandler.java index b9e7ef5..5fd7ca0 100644 --- a/src/main/java/com/litoralregas/openvpn/common/ApiExceptionHandler.java +++ b/src/main/java/com/litoralregas/openvpn/common/ApiExceptionHandler.java @@ -15,9 +15,22 @@ public class ApiExceptionHandler { return Map.of("error", exception.getMessage()); } + @ResponseStatus(HttpStatus.CONFLICT) + @ExceptionHandler(IllegalStateException.class) + public Map handleIllegalState(IllegalStateException exception) { + return Map.of("error", exception.getMessage()); + } + @ResponseStatus(HttpStatus.BAD_REQUEST) @ExceptionHandler(MethodArgumentNotValidException.class) public Map handleValidation(MethodArgumentNotValidException exception) { return Map.of("error", "Validation failed"); } + + @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR) + @ExceptionHandler(Exception.class) + public Map handleGeneric(Exception exception) { + return Map.of("error", "Internal server error"); + } + } \ No newline at end of file