diff --git a/src/main/java/me/braydon/mc/exception/ExceptionControllerAdvice.java b/src/main/java/me/braydon/mc/exception/ExceptionControllerAdvice.java index d38b0c3..8bc891f 100644 --- a/src/main/java/me/braydon/mc/exception/ExceptionControllerAdvice.java +++ b/src/main/java/me/braydon/mc/exception/ExceptionControllerAdvice.java @@ -1,7 +1,7 @@ package me.braydon.mc.exception; import lombok.NonNull; -import me.braydon.mc.model.response.ErrorResponse; +import me.braydon.mc.model.ErrorResponse; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.ControllerAdvice; @@ -15,6 +15,12 @@ import org.springframework.web.bind.annotation.ResponseStatus; */ @ControllerAdvice public final class ExceptionControllerAdvice { + /** + * Handle a raised exception. + * + * @param ex the raised exception + * @return the error response + */ @ExceptionHandler(Exception.class) public ResponseEntity handleException(@NonNull Exception ex) { HttpStatus status = HttpStatus.INTERNAL_SERVER_ERROR; // Get the HTTP status @@ -25,6 +31,7 @@ public final class ExceptionControllerAdvice { if (message == null) { // Fallback message = "An internal error has occurred."; } + ex.printStackTrace(); // Print the stack trace return new ResponseEntity<>(new ErrorResponse(status, message), status); } } \ No newline at end of file diff --git a/src/main/java/me/braydon/mc/exception/impl/BadRequestException.java b/src/main/java/me/braydon/mc/exception/impl/BadRequestException.java new file mode 100644 index 0000000..77edc22 --- /dev/null +++ b/src/main/java/me/braydon/mc/exception/impl/BadRequestException.java @@ -0,0 +1,15 @@ +package me.braydon.mc.exception.impl; + +import lombok.experimental.StandardException; +import org.springframework.http.HttpStatus; +import org.springframework.web.bind.annotation.ResponseStatus; + +/** + * This exception is raised + * when a bad request is made. + * + * @author Braydon + */ +@StandardException +@ResponseStatus(HttpStatus.BAD_REQUEST) +public final class BadRequestException extends RuntimeException { } \ No newline at end of file