HerdErrorInformationExceptionHandler { @ExceptionHandler(value = ActivitiException.class) @ResponseBody public ErrorInformation handleActivitiException(Exception exception, HttpServletResponse response) { if ((ExceptionUtils.indexOfThrowable(exception, ActivitiClassLoadingException.class) != -1) || (ExceptionUtils.indexOfType(exception, ELException.class) != -1)) { return getErrorInformationAndSetStatus(HttpStatus.BAD_REQUEST, exception, response); } else { logError("An Activiti error occurred.", exception); return getErrorInformationAndSetStatus(HttpStatus.INTERNAL_SERVER_ERROR, exception, response); } }  @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 testActivitiExceptionBadRequest() throws Exception { validateErrorInformation(exceptionHandler .handleActivitiException(new ActivitiClassLoadingException(ActivitiClassLoadingException.class.getName(), new RuntimeException(MESSAGE)), new MockHttpServletResponse()), HttpStatus.BAD_REQUEST, false); validateErrorInformation(exceptionHandler.handleActivitiException(new ELException(MESSAGE), new MockHttpServletResponse()), HttpStatus.BAD_REQUEST); }
@Test public void testActivitiExceptionInternalServerError() throws Exception { validateErrorInformation(exceptionHandler.handleActivitiException(new ActivitiException(MESSAGE), new MockHttpServletResponse()), HttpStatus.INTERNAL_SERVER_ERROR, false); }