add userMessage for unspecified exception
parent
cca446650d
commit
ad22b09877
|
|
@ -19,23 +19,24 @@ public class GlobalExceptionHandler {
|
|||
@ExceptionHandler(ARException.class)
|
||||
public ResponseEntity<ErrorResponse> handleARException(ARException e, HttpServletRequest request) {
|
||||
var errorMessage = "Remedy server error: " + e.getMessage();
|
||||
return entityResponse(errorMessage, e, HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
return entityResponse(errorMessage, errorMessage, e, HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
|
||||
@ExceptionHandler(Exception.class)
|
||||
public ResponseEntity<ErrorResponse> handleGenericException(Exception e, HttpServletRequest request) {
|
||||
var errorMessage = "Backend internal server error: " + e.getMessage();
|
||||
return entityResponse(errorMessage, e, HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
var userMessage = "Backend internal server error";
|
||||
return entityResponse(userMessage, e.getMessage(), e, HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
|
||||
@ExceptionHandler(BackendError.class)
|
||||
public ResponseEntity<ErrorResponse> handleBackendErrorException(BackendError e, HttpServletRequest request) {
|
||||
var errorMessage = "Backend internal server error: " + e.getMessage();
|
||||
return entityResponse(errorMessage, e, e.getHttpStatus());
|
||||
return entityResponse(errorMessage, errorMessage, e, e.getHttpStatus());
|
||||
}
|
||||
|
||||
private ResponseEntity<ErrorResponse> entityResponse(String errorMessage, Exception e, HttpStatus status) {
|
||||
var errorResponse = new ErrorResponse(errorMessage, e.getClass().getSimpleName());
|
||||
private ResponseEntity<ErrorResponse> entityResponse(String userMessage, String errorMessage, Exception e,
|
||||
HttpStatus status) {
|
||||
var errorResponse = new ErrorResponse(userMessage, e.getClass().getSimpleName());
|
||||
errorLogger.error(errorMessage, e);
|
||||
return new ResponseEntity<>(errorResponse, status);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue