class HerdErrorInformationExceptionHandler {

    @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;
    }

}