test_class.declarator: exceptionHandler
test_class.modifier: @Autowired
      private
test_class.original_string: @Autowired
      private HerdErrorInformationExceptionHandler exceptionHandler;
test_class.type: HerdErrorInformationExceptionHandler
test_class.var_name: exceptionHandler
test_class.declarator: MESSAGE = "This is a test and is not an actual error. Please ignore."
test_class.modifier: private static final
test_class.original_string: private static final String MESSAGE = "This is a test and is not an actual error. Please ignore.";
test_class.type: String
test_class.var_name: MESSAGE
test_class.file: herd-code/herd-service/src/test/java/org/finra/herd/service/helper/HerdErrorInformationExceptionHandlerTest.java
test_class.identifier: HerdErrorInformationExceptionHandlerTest
test_class.superclass: extends AbstractServiceTest
test_case.body: @Test
      public void testIsReportableErrorThrowable() throws Exception
      {
          assertTrue(exceptionHandler.isReportableError(new Throwable(MESSAGE)));
      }
test_case.class_method_signature: HerdErrorInformationExceptionHandlerTest.testIsReportableErrorThrowable()
test_case.full_signature: @Test public void testIsReportableErrorThrowable()
test_case.identifier: testIsReportableErrorThrowable
test_case.invocations: assertTrue isReportableError
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testIsReportableErrorThrowable()
focal_class.declarator: ORACLE_DATA_TOO_LARGE_ERROR_CODE = 12899
focal_class.modifier: public static final
focal_class.original_string: public static final int ORACLE_DATA_TOO_LARGE_ERROR_CODE = 12899;
focal_class.type: int
focal_class.var_name: ORACLE_DATA_TOO_LARGE_ERROR_CODE
focal_class.declarator: ORACLE_LONG_DATA_IN_LONG_COLUMN_ERROR_CODE = 1461
focal_class.modifier: public static final
focal_class.original_string: public static final int ORACLE_LONG_DATA_IN_LONG_COLUMN_ERROR_CODE = 1461;
focal_class.type: int
focal_class.var_name: ORACLE_LONG_DATA_IN_LONG_COLUMN_ERROR_CODE
focal_class.declarator: ORACLE_SQL_STATE_CODE_ERROR = "72000"
focal_class.modifier: public static final
focal_class.original_string: public static final String ORACLE_SQL_STATE_CODE_ERROR = "72000";
focal_class.type: String
focal_class.var_name: ORACLE_SQL_STATE_CODE_ERROR
focal_class.declarator: POSTGRES_SQL_STATE_CODE_FOREIGN_KEY_VIOLATION = "23503"
focal_class.modifier: public static final
focal_class.original_string: public static final String POSTGRES_SQL_STATE_CODE_FOREIGN_KEY_VIOLATION = "23503";
focal_class.type: String
focal_class.var_name: POSTGRES_SQL_STATE_CODE_FOREIGN_KEY_VIOLATION
focal_class.declarator: POSTGRES_SQL_STATE_CODE_UNIQUE_INDEX_OR_PRIMARY_KEY_VIOLATION = "23505"
focal_class.modifier: public static final
focal_class.original_string: public static final String POSTGRES_SQL_STATE_CODE_UNIQUE_INDEX_OR_PRIMARY_KEY_VIOLATION = "23505";
focal_class.type: String
focal_class.var_name: POSTGRES_SQL_STATE_CODE_UNIQUE_INDEX_OR_PRIMARY_KEY_VIOLATION
focal_class.declarator: POSTGRES_SQL_STATE_CODE_TRUNCATION_ERROR = "22001"
focal_class.modifier: public static final
focal_class.original_string: public static final String POSTGRES_SQL_STATE_CODE_TRUNCATION_ERROR = "22001";
focal_class.type: String
focal_class.var_name: POSTGRES_SQL_STATE_CODE_TRUNCATION_ERROR
focal_class.declarator: LOGGER = LoggerFactory.getLogger(HerdErrorInformationExceptionHandler.class)
focal_class.modifier: private static final
focal_class.original_string: private static final Logger LOGGER = LoggerFactory.getLogger(HerdErrorInformationExceptionHandler.class);
focal_class.type: Logger
focal_class.var_name: LOGGER
focal_class.declarator: loggingEnabled = false
focal_class.modifier: private
focal_class.original_string: private boolean loggingEnabled = false;
focal_class.type: boolean
focal_class.var_name: loggingEnabled
focal_class.declarator: resolver
focal_class.modifier: @Autowired
      private
focal_class.original_string: @Autowired
      private ExceptionHandlerMethodResolver resolver;
focal_class.type: ExceptionHandlerMethodResolver
focal_class.var_name: resolver
focal_class.file: herd-code/herd-service/src/main/java/org/finra/herd/service/helper/HerdErrorInformationExceptionHandler.java
focal_class.identifier: HerdErrorInformationExceptionHandler
focal_class.class_method_signature: HerdErrorInformationExceptionHandler.handleAccessDeniedException(Exception exception)
focal_class.full_signature: @ExceptionHandler(value = AccessDeniedException.class) @ResponseStatus(HttpStatus.FORBIDDEN) @ResponseBody public ErrorInformation handleAccessDeniedException(Exception exception)
focal_class.identifier: handleAccessDeniedException
focal_class.modifiers: @ExceptionHandler(value = AccessDeniedException.class) @ResponseStatus(HttpStatus.FORBIDDEN) @ResponseBody public
focal_class.parameters: (Exception exception)
focal_class.return: ErrorInformation
focal_class.signature: ErrorInformation handleAccessDeniedException(Exception exception)
focal_class.class_method_signature: HerdErrorInformationExceptionHandler.handleActivitiException(Exception exception, HttpServletResponse response)
focal_class.full_signature: @ExceptionHandler(value = ActivitiException.class) @ResponseBody public ErrorInformation handleActivitiException(Exception exception, HttpServletResponse response)
focal_class.identifier: handleActivitiException
focal_class.modifiers: @ExceptionHandler(value = ActivitiException.class) @ResponseBody public
focal_class.parameters: (Exception exception, HttpServletResponse response)
focal_class.return: ErrorInformation
focal_class.signature: ErrorInformation handleActivitiException(Exception exception, HttpServletResponse response)
focal_class.class_method_signature: HerdErrorInformationExceptionHandler.handleBadRequestException(Exception exception)
focal_class.full_signature: @ExceptionHandler(value = {IllegalArgumentException.class, HttpMessageNotReadableException.class, MissingServletRequestParameterException.class, TypeMismatchException.class, UnsupportedEncodingException.class}) @ResponseStatus(HttpStatus.BAD_REQUEST) @ResponseBody public ErrorInformation handleBadRequestException(Exception exception)
focal_class.identifier: handleBadRequestException
focal_class.modifiers: @ExceptionHandler(value = {IllegalArgumentException.class, HttpMessageNotReadableException.class, MissingServletRequestParameterException.class, TypeMismatchException.class, UnsupportedEncodingException.class}) @ResponseStatus(HttpStatus.BAD_REQUEST) @ResponseBody public
focal_class.parameters: (Exception exception)
focal_class.return: ErrorInformation
focal_class.signature: ErrorInformation handleBadRequestException(Exception exception)
focal_class.class_method_signature: HerdErrorInformationExceptionHandler.handleConflictException(Exception exception)
focal_class.full_signature: @ExceptionHandler(value = {AlreadyExistsException.class, ObjectAlreadyExistsException.class, OptimisticLockException.class}) @ResponseStatus(HttpStatus.CONFLICT) @ResponseBody public ErrorInformation handleConflictException(Exception exception)
focal_class.identifier: handleConflictException
focal_class.modifiers: @ExceptionHandler(value = {AlreadyExistsException.class, ObjectAlreadyExistsException.class, OptimisticLockException.class}) @ResponseStatus(HttpStatus.CONFLICT) @ResponseBody public
focal_class.parameters: (Exception exception)
focal_class.return: ErrorInformation
focal_class.signature: ErrorInformation handleConflictException(Exception exception)
focal_class.class_method_signature: HerdErrorInformationExceptionHandler.handleInternalServerErrorException(Exception exception)
focal_class.full_signature: @ExceptionHandler(value = Exception.class) @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR) @ResponseBody public ErrorInformation handleInternalServerErrorException(Exception exception)
focal_class.identifier: handleInternalServerErrorException
focal_class.modifiers: @ExceptionHandler(value = Exception.class) @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR) @ResponseBody public
focal_class.parameters: (Exception exception)
focal_class.return: ErrorInformation
focal_class.signature: ErrorInformation handleInternalServerErrorException(Exception exception)
focal_class.class_method_signature: HerdErrorInformationExceptionHandler.handleNotFoundException(RuntimeException exception)
focal_class.full_signature: @ExceptionHandler(value = {org.hibernate.ObjectNotFoundException.class, ObjectNotFoundException.class}) @ResponseStatus(HttpStatus.NOT_FOUND) @ResponseBody public ErrorInformation handleNotFoundException(RuntimeException exception)
focal_class.identifier: handleNotFoundException
focal_class.modifiers: @ExceptionHandler(value = {org.hibernate.ObjectNotFoundException.class, ObjectNotFoundException.class}) @ResponseStatus(HttpStatus.NOT_FOUND) @ResponseBody public
focal_class.parameters: (RuntimeException exception)
focal_class.return: ErrorInformation
focal_class.signature: ErrorInformation handleNotFoundException(RuntimeException exception)
focal_class.class_method_signature: HerdErrorInformationExceptionHandler.handleOperationNotAllowedException(RuntimeException exception)
focal_class.full_signature: @ExceptionHandler(value = MethodNotAllowedException.class) @ResponseStatus(HttpStatus.METHOD_NOT_ALLOWED) @ResponseBody public ErrorInformation handleOperationNotAllowedException(RuntimeException exception)
focal_class.identifier: handleOperationNotAllowedException
focal_class.modifiers: @ExceptionHandler(value = MethodNotAllowedException.class) @ResponseStatus(HttpStatus.METHOD_NOT_ALLOWED) @ResponseBody public
focal_class.parameters: (RuntimeException exception)
focal_class.return: ErrorInformation
focal_class.signature: ErrorInformation handleOperationNotAllowedException(RuntimeException exception)
focal_class.class_method_signature: HerdErrorInformationExceptionHandler.handlePersistenceException(Exception exception, HttpServletResponse response)
focal_class.full_signature: @ExceptionHandler(value = {JpaSystemException.class, PersistenceException.class}) @ResponseBody public ErrorInformation handlePersistenceException(Exception exception, HttpServletResponse response)
focal_class.identifier: handlePersistenceException
focal_class.modifiers: @ExceptionHandler(value = {JpaSystemException.class, PersistenceException.class}) @ResponseBody public
focal_class.parameters: (Exception exception, HttpServletResponse response)
focal_class.return: ErrorInformation
focal_class.signature: ErrorInformation handlePersistenceException(Exception exception, HttpServletResponse response)
focal_class.class_method_signature: HerdErrorInformationExceptionHandler.isLoggingEnabled()
focal_class.full_signature: public boolean isLoggingEnabled()
focal_class.identifier: isLoggingEnabled
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: boolean
focal_class.signature: boolean isLoggingEnabled()
focal_class.class_method_signature: HerdErrorInformationExceptionHandler.setLoggingEnabled(boolean loggingEnabled)
focal_class.full_signature: public void setLoggingEnabled(boolean loggingEnabled)
focal_class.identifier: setLoggingEnabled
focal_class.modifiers: public
focal_class.parameters: (boolean loggingEnabled)
focal_class.return: void
focal_class.signature: void setLoggingEnabled(boolean loggingEnabled)
focal_class.class_method_signature: HerdErrorInformationExceptionHandler.isReportableError(Throwable exception)
focal_class.full_signature: @SuppressWarnings({"unchecked", "rawtypes"}) public boolean isReportableError(Throwable exception)
focal_class.identifier: isReportableError
focal_class.modifiers: @SuppressWarnings({"unchecked", "rawtypes"}) public
focal_class.parameters: (Throwable exception)
focal_class.return: boolean
focal_class.signature: boolean isReportableError(Throwable exception)
focal_class.class_method_signature: HerdErrorInformationExceptionHandler.getErrorInformation(HttpStatus httpStatus, Throwable exception)
focal_class.full_signature: private ErrorInformation getErrorInformation(HttpStatus httpStatus, Throwable exception)
focal_class.identifier: getErrorInformation
focal_class.modifiers: private
focal_class.parameters: (HttpStatus httpStatus, Throwable exception)
focal_class.return: ErrorInformation
focal_class.signature: ErrorInformation getErrorInformation(HttpStatus httpStatus, Throwable exception)
focal_class.class_method_signature: HerdErrorInformationExceptionHandler.getErrorInformationAndSetStatus(HttpStatus httpStatus, Throwable exception, HttpServletResponse response)
focal_class.full_signature: private ErrorInformation getErrorInformationAndSetStatus(HttpStatus httpStatus, Throwable exception, HttpServletResponse response)
focal_class.identifier: getErrorInformationAndSetStatus
focal_class.modifiers: private
focal_class.parameters: (HttpStatus httpStatus, Throwable exception, HttpServletResponse response)
focal_class.return: ErrorInformation
focal_class.signature: ErrorInformation getErrorInformationAndSetStatus(HttpStatus httpStatus, Throwable exception, HttpServletResponse response)
focal_class.class_method_signature: HerdErrorInformationExceptionHandler.getRootCause(Exception throwable)
focal_class.full_signature: private Throwable getRootCause(Exception throwable)
focal_class.identifier: getRootCause
focal_class.modifiers: private
focal_class.parameters: (Exception throwable)
focal_class.return: Throwable
focal_class.signature: Throwable getRootCause(Exception throwable)
focal_class.class_method_signature: HerdErrorInformationExceptionHandler.isCausedByConstraintViolationException(Exception exception)
focal_class.full_signature: private boolean isCausedByConstraintViolationException(Exception exception)
focal_class.identifier: isCausedByConstraintViolationException
focal_class.modifiers: private
focal_class.parameters: (Exception exception)
focal_class.return: boolean
focal_class.signature: boolean isCausedByConstraintViolationException(Exception exception)
focal_class.class_method_signature: HerdErrorInformationExceptionHandler.isDataTruncationException(Throwable throwable)
focal_class.full_signature: private boolean isDataTruncationException(Throwable throwable)
focal_class.identifier: isDataTruncationException
focal_class.modifiers: private
focal_class.parameters: (Throwable throwable)
focal_class.return: boolean
focal_class.signature: boolean isDataTruncationException(Throwable throwable)
focal_class.class_method_signature: HerdErrorInformationExceptionHandler.logError(String message, Exception exception)
focal_class.full_signature: protected void logError(String message, Exception exception)
focal_class.identifier: logError
focal_class.modifiers: protected
focal_class.parameters: (String message, Exception exception)
focal_class.return: void
focal_class.signature: void logError(String message, Exception exception)
focal_method.body: @SuppressWarnings({"unchecked", "rawtypes"})
      public boolean isReportableError(Throwable exception)
      {
          // By default, the exception is reportable (i.e. the safe route).
          boolean isReportable = true;
  
          // Only proceed if we have an exception (as opposed to another Throwable) since the exception resolver only works off "exceptions".
          if (exception instanceof Exception)
          {
              // Try to resolve the exception which should yield a method on our exception handler (i.e. this class).
              Method method = resolver.resolveMethod((Exception) exception);
  
              // Only proceed if we found a valid method and it returns error information. Error information is needed to make the determination
              // whether or not the exception is reportable.
              if ((method != null) && (ErrorInformation.class.isAssignableFrom(method.getReturnType())))
              {
                  // Create a list of parameters we will need to pass to the method being invoking.
                  List<Object> parameterValues = new ArrayList<>();
  
                  // Get the method parameters as an array of "classes".
                  Class[] parameterTypes = method.getParameterTypes();
  
                  // Loop through the method class parameter types and add a parameter value for each one.
                  // The parameter will be the exception itself or null for all other cases. Note that we need to ensure that if the handler method takes
                  // additional parameters besides exceptions (i.e. the ones we will pass null), that the handler method will "handle" the null case
                  // and not throw a null pointer exception.
                  for (Class clazz : parameterTypes)
                  {
                      if (clazz.isAssignableFrom(exception.getClass()))
                      {
                          // The parameter class is assignable from the actual exception so pass the exception itself.
                          parameterValues.add(exception);
                      }
                      else
                      {
                          // The parameter class is something else so pass null.
                          parameterValues.add(null);
                      }
                  }
  
                  try
                  {
                      // Invoke the handler method specific to our exception and get the error information back.
                      ErrorInformation errorInformation = (ErrorInformation) method.invoke(this, parameterValues.toArray());
  
                      // The only error information status that is reportable is "internal server error" so set the flag to false for all other cases.
                      if (errorInformation.getStatusCode() != HttpStatus.INTERNAL_SERVER_ERROR.value())
                      {
                          isReportable = false;
                      }
                  }
                  catch (IllegalAccessException | InvocationTargetException ex)
                  {
                      logError("Unable to invoke method \"" + method.getDeclaringClass().getName() + "." + method.getName() +
                          "\" so couldn't determine if exception is reportable. Defaulting to true.", ex);
                  }
              }
          }
  
          // Return whether the error should be reported.
          return isReportable;
      }
focal_method.class_method_signature: HerdErrorInformationExceptionHandler.isReportableError(Throwable exception)
focal_method.full_signature: @SuppressWarnings({"unchecked", "rawtypes"}) public boolean isReportableError(Throwable exception)
focal_method.identifier: isReportableError
focal_method.invocations: resolveMethod isAssignableFrom getReturnType getParameterTypes isAssignableFrom getClass add add invoke toArray getStatusCode value logError getName getDeclaringClass getName
focal_method.modifiers: @SuppressWarnings({"unchecked", "rawtypes"}) public
focal_method.parameters: (Throwable exception)
focal_method.return: boolean
focal_method.signature: boolean isReportableError(Throwable exception)