HerdErrorInformationExceptionHandler { @ExceptionHandler(value = Exception.class) @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR) @ResponseBody public ErrorInformation handleInternalServerErrorException(Exception exception) { logError("A general error occurred.", exception); return getErrorInformation(HttpStatus.INTERNAL_SERVER_ERROR, exception); }  @ExceptionHandler(value = AccessDeniedException.class) @ResponseStatus(HttpStatus.FORBIDDEN) @ResponseBody ErrorInformation handleAccessDeniedException(Exception exception); @ExceptionHandler(value = ActivitiException.class) @ResponseBody ErrorInformation handleActivitiException(Exception exception, HttpServletResponse response); @ExceptionHandler(value = {IllegalArgumentException.class, HttpMessageNotReadableException.class, MissingServletRequestParameterException.class, TypeMismatchException.class, UnsupportedEncodingException.class}) @ResponseStatus(HttpStatus.BAD_REQUEST) @ResponseBody ErrorInformation handleBadRequestException(Exception exception); @ExceptionHandler(value = {AlreadyExistsException.class, ObjectAlreadyExistsException.class, OptimisticLockException.class}) @ResponseStatus(HttpStatus.CONFLICT) @ResponseBody ErrorInformation handleConflictException(Exception exception); @ExceptionHandler(value = Exception.class) @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR) @ResponseBody ErrorInformation handleInternalServerErrorException(Exception exception); @ExceptionHandler(value = {org.hibernate.ObjectNotFoundException.class, ObjectNotFoundException.class}) @ResponseStatus(HttpStatus.NOT_FOUND) @ResponseBody ErrorInformation handleNotFoundException(RuntimeException exception); @ExceptionHandler(value = MethodNotAllowedException.class) @ResponseStatus(HttpStatus.METHOD_NOT_ALLOWED) @ResponseBody ErrorInformation handleOperationNotAllowedException(RuntimeException exception); @ExceptionHandler(value = {JpaSystemException.class, PersistenceException.class}) @ResponseBody ErrorInformation handlePersistenceException(Exception exception, HttpServletResponse response); boolean isLoggingEnabled(); void setLoggingEnabled(boolean loggingEnabled); @SuppressWarnings({"unchecked", "rawtypes"}) boolean isReportableError(Throwable exception); static final int ORACLE_DATA_TOO_LARGE_ERROR_CODE; static final int ORACLE_LONG_DATA_IN_LONG_COLUMN_ERROR_CODE; static final String ORACLE_SQL_STATE_CODE_ERROR; static final String POSTGRES_SQL_STATE_CODE_FOREIGN_KEY_VIOLATION; static final String POSTGRES_SQL_STATE_CODE_UNIQUE_INDEX_OR_PRIMARY_KEY_VIOLATION; static final String POSTGRES_SQL_STATE_CODE_TRUNCATION_ERROR; }
@Test public void testHandleInternalServerError() throws Exception { validateErrorInformation(exceptionHandler.handleInternalServerErrorException(new Exception(MESSAGE)), HttpStatus.INTERNAL_SERVER_ERROR); }
@Test public void testHandleInternalServerErrorNoErrorMessage() throws Exception { ErrorInformation errorInformation = exceptionHandler.handleInternalServerErrorException(new NullPointerException()); validateErrorInformation(errorInformation, HttpStatus.INTERNAL_SERVER_ERROR, false); assertEquals(NullPointerException.class.getName(), errorInformation.getMessage()); }