[DS-4014] added a catch in the DSpaceApiExceptionControllerAdvice for a generic exception and throws a 500 with cors headers available

This commit is contained in:
Raf Ponsaerts
2018-09-21 16:27:26 +02:00
committed by Tom Desair
parent d7ec9e537a
commit 7c122e55aa

View File

@@ -102,6 +102,13 @@ public class DSpaceApiExceptionControllerAdvice extends ResponseEntityExceptionH
return super.handleTypeMismatch(ex, headers, HttpStatus.UNPROCESSABLE_ENTITY, request);
}
@ExceptionHandler(Exception.class)
protected void handleGenericException(HttpServletRequest request, HttpServletResponse response, Exception ex)
throws IOException {
sendErrorResponse(request, response, ex, "An Exception has occured",
HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
}
private void sendErrorResponse(final HttpServletRequest request, final HttpServletResponse response,
final Exception ex, final String message, final int statusCode) throws IOException {
//Make sure Spring picks up this exception