class 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))
        {
            // These exceptions are caused by invalid workflow configurations (i.e. user error) so they are considered a bad request.
            return getErrorInformationAndSetStatus(HttpStatus.BAD_REQUEST, exception, response);
        }
        else
        {
            // For all other exceptions, something is wrong that we weren't expecting so we'll return this as an internal server error and log the error.
            logError("An Activiti error occurred.", exception);
            return getErrorInformationAndSetStatus(HttpStatus.INTERNAL_SERVER_ERROR, exception, response);
        }
    }

}