@Override public ApiExceptionHandlerListenerResult shouldHandleException(Throwable ex) { ServersideValidationError sve = null; // Try to get the ServersideValidationError if (ex instanceof ServersideValidationError) sve = (ServersideValidationError)ex; else if ((ex instanceof DownstreamRequestOrResponseBodyFailedValidationException) && (ex.getCause() instanceof ServersideValidationError)) { sve = (ServersideValidationError) ex.getCause(); } if (sve != null) { // Process the ServersideValidationError to add logging details and get the appropriate SortedApiErrorSet. List<Pair<String, String>> extraDetailsForLogging = new ArrayList<>(); SortedApiErrorSet apiErrors = processServersideValidationError(sve, extraDetailsForLogging); return ApiExceptionHandlerListenerResult.handleResponse(apiErrors, extraDetailsForLogging); } // Not an exception we know how to handle - ignore it. return ApiExceptionHandlerListenerResult.ignoreResponse(); }
/** * @return The basic set of handler listeners that are appropriate for most JAX-RS applications. */ public static List<ApiExceptionHandlerListener> defaultApiExceptionHandlerListeners( ProjectApiErrors projectApiErrors, ApiExceptionHandlerUtils utils ) { return Arrays.asList( new GenericApiExceptionHandlerListener(), new ServersideValidationErrorHandlerListener(projectApiErrors, utils), new ClientDataValidationErrorHandlerListener(projectApiErrors, utils), new DownstreamNetworkExceptionHandlerListener(projectApiErrors), new JaxRsWebApplicationExceptionHandlerListener(projectApiErrors, utils)); }
/** * Returns the default list of {@link ApiExceptionHandlerListener}s that should work for most applications without * any further additions. */ public static List<ApiExceptionHandlerListener> defaultHandlerListeners(ProjectApiErrors projectApiErrors, ApiExceptionHandlerUtils utils) { return Arrays.asList(new GenericApiExceptionHandlerListener(), new ServersideValidationErrorHandlerListener(projectApiErrors, utils), new ClientDataValidationErrorHandlerListener(projectApiErrors, utils), new DownstreamNetworkExceptionHandlerListener(projectApiErrors), new BackstopperRiposteFrameworkErrorHandlerListener(projectApiErrors)); }