Skip to content

Commit

Permalink
Fix exception messages
Browse files Browse the repository at this point in the history
  • Loading branch information
nelifs committed Dec 27, 2024
1 parent ab14e34 commit a6db0e5
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ public ExceptionController(APIConfig apiConfig) {
}

private ResponseEntity<ExceptionDTO> buildErrorResponse(int errorCode, String message, HttpStatus status) {
if (!apiConfig.isDevelopment()) message = ExceptionsConstants.Messages.INTERNAL_ERROR.getValue();

log.error(ExceptionsConstants.Messages.SERVER_EXCEPTION.getValue(), errorCode, status, message);
return ResponseEntity.status(status).body(new ExceptionDTO(false, errorCode, message));
}
Expand All @@ -53,7 +51,10 @@ public ResponseEntity<ExceptionDTO> handleValidationException(MethodArgumentNotV

@ExceptionHandler(Exception.class)
public ResponseEntity<ExceptionDTO> handleException(Exception exception) {
String message = exception.getMessage();
if (!apiConfig.isDevelopment()) message = ExceptionsConstants.Messages.INTERNAL_ERROR.getValue();

log.error(ExceptionsConstants.Messages.SERVER_EXCEPTION_STACKTRACE.getValue(), exception);
return buildErrorResponse(ExceptionsConstants.Unknown.ERROR.getValue(), exception.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR);
return buildErrorResponse(ExceptionsConstants.Unknown.ERROR.getValue(), message, HttpStatus.INTERNAL_SERVER_ERROR);
}
}

0 comments on commit a6db0e5

Please sign in to comment.