Don't return exception message in ControllerAdvice

This commit is contained in:
2025-01-31 11:12:32 +01:00
parent 12d330fa6f
commit c2bfbb5bec

View File

@ -18,7 +18,7 @@ public class ControllerAdvice {
@ExceptionHandler(value = {RuntimeException.class}) @ExceptionHandler(value = {RuntimeException.class})
public ResponseEntity<ErrorResponse> handleRuntimeException(Exception e) { public ResponseEntity<ErrorResponse> handleRuntimeException(Exception e) {
e.printStackTrace(); e.printStackTrace();
var response = new ErrorResponse(e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR.value()); var response = new ErrorResponse("An internal error occurred", HttpStatus.INTERNAL_SERVER_ERROR.value());
return new ResponseEntity<>(response, HttpStatus.INTERNAL_SERVER_ERROR); return new ResponseEntity<>(response, HttpStatus.INTERNAL_SERVER_ERROR);
} }
} }