/** * @return An {@link ApiExceptionHandlerListenerResult} indicating whether we should handle the given exception. * If {@link ApiExceptionHandlerListenerResult#shouldHandleResponse} is true then * {@link ApiExceptionHandlerListenerResult#errors} and * {@link ApiExceptionHandlerListenerResult#extraDetailsForLogging} must be filled in appropriately and * ready for passing in to * {@link #doHandleApiException(SortedApiErrorSet, List, List, Throwable, RequestInfoForLogging)}. If it is * false then the given exception will be ignored by this class (and should therefore ultimately be handled * by this project's implementation of {@link UnhandledExceptionHandlerBase}). */ protected ApiExceptionHandlerListenerResult shouldHandleApiException(Throwable ex) { // The original exception might be a "wrapper" exception. If so, unwrap it so we can send the core exception // through our list of listeners. Throwable coreEx = unwrapAndFindCoreException(ex); // Run through each listener looking for one that wants to handle the core exception. for (ApiExceptionHandlerListener listener : apiExceptionHandlerListenerList) { ApiExceptionHandlerListenerResult result = listener.shouldHandleException(coreEx); if (result.shouldHandleResponse) return result; } // We didn't have any handler that wanted to deal with this exception, so return an "ignore it" response. return ApiExceptionHandlerListenerResult.ignoreResponse(); }