@@ -20,11 +20,11 @@ public class RestExceptionHandler extends ResponseEntityExceptionHandler {
2020 * Handles all {@link MethodArgumentTypeMismatchException}s.
2121 *
2222 * @param e The {@link MethodArgumentTypeMismatchException} which was thrown.
23- * @return The {@link ResponseEntity} containing the {@link ApiError }.
23+ * @return The {@link ResponseEntity} containing the {@link ErrorResponse }.
2424 */
25- @ ExceptionHandler ({ MethodArgumentTypeMismatchException .class } )
26- public ResponseEntity <ApiError > handleMethodArgumentTypeMismatch (@ NotNull MethodArgumentTypeMismatchException e ) {
27- ApiError error = new ApiError (HttpStatus .BAD_REQUEST , e .getLocalizedMessage (),
25+ @ ExceptionHandler (MethodArgumentTypeMismatchException .class )
26+ public ResponseEntity <ErrorResponse > handleMethodArgumentTypeMismatch (@ NotNull MethodArgumentTypeMismatchException e ) {
27+ ErrorResponse error = new ErrorResponse (HttpStatus .BAD_REQUEST , e .getLocalizedMessage (),
2828 String .format ("%s should be of type %s" , e .getName (), e .getRequiredType () != null ? e .getRequiredType ().getName () : "" ));
2929 return new ResponseEntity <>(error , error .status ());
3030 }
@@ -33,23 +33,23 @@ public ResponseEntity<ApiError> handleMethodArgumentTypeMismatch(@NotNull Method
3333 * Handles all {@link InvalidEntityIdException}s.
3434 *
3535 * @param e The {@link InvalidEntityIdException} which was thrown.
36- * @return The {@link ResponseEntity} containing the {@link ApiError }.
36+ * @return The {@link ResponseEntity} containing the {@link ErrorResponse }.
3737 */
38- @ ExceptionHandler ({ InvalidEntityIdException .class } )
39- public ResponseEntity <ApiError > handleInvalidEntityIdException (@ NotNull InvalidEntityIdException e ) {
40- ApiError error = new ApiError (HttpStatus .BAD_REQUEST , e .getLocalizedMessage (), "Entity should be of type: " + e .getRequiredEntity ().getName ());
38+ @ ExceptionHandler (InvalidEntityIdException .class )
39+ public ResponseEntity <ErrorResponse > handleInvalidEntityIdException (@ NotNull InvalidEntityIdException e ) {
40+ ErrorResponse error = new ErrorResponse (HttpStatus .BAD_REQUEST , e .getLocalizedMessage (), "Entity should be of type: " + e .getRequiredEntity ().getName ());
4141 return new ResponseEntity <>(error , error .status ());
4242 }
4343
4444 /**
4545 * Handles all {@link SQLException}s.
4646 *
4747 * @param e The {@link SQLException} which was thrown.
48- * @return The {@link ResponseEntity} containing the {@link ApiError }.
48+ * @return The {@link ResponseEntity} containing the {@link ErrorResponse }.
4949 */
5050 @ ExceptionHandler ({ InternalServerException .class })
51- public ResponseEntity <ApiError > handleInternalServerException (@ NotNull InternalServerException e ) {
52- ApiError error = new ApiError (HttpStatus .BAD_REQUEST , e .getCause ().getLocalizedMessage (), e .getLocalizedMessage ());
51+ public ResponseEntity <ErrorResponse > handleInternalServerException (@ NotNull InternalServerException e ) {
52+ ErrorResponse error = new ErrorResponse (HttpStatus .BAD_REQUEST , e .getCause ().getLocalizedMessage (), e .getLocalizedMessage ());
5353 return new ResponseEntity <>(error , error .status ());
5454 }
5555}
0 commit comments