@Override public ApiExceptionHandlerListenerResult shouldHandleException(Throwable ex) { // We only care about ClientDataValidationErrors. if (ex instanceof ClientDataValidationError) { List<Pair<String, String>> extraDetailsForLogging = new ArrayList<>(); SortedApiErrorSet apiErrors = processClientDataValidationError( (ClientDataValidationError)ex, extraDetailsForLogging ); return ApiExceptionHandlerListenerResult.handleResponse(apiErrors, extraDetailsForLogging); } // Not a ClientDataValidationError. Ignore. return ApiExceptionHandlerListenerResult.ignoreResponse(); }
@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(); }
@Override public ApiExceptionHandlerListenerResult shouldHandleException(Throwable ex) { // We only care about ApiExceptions. if (!(ex instanceof ApiException)) return ApiExceptionHandlerListenerResult.ignoreResponse(); ApiException apiException = ((ApiException)ex); // Add all the ApiErrors from the exception. SortedApiErrorSet errors = new SortedApiErrorSet(); errors.addAll(apiException.getApiErrors()); // Add all the extra details for logging from the exception. List<Pair<String, String>> messages = new ArrayList<>(); messages.addAll(apiException.getExtraDetailsForLogging()); // Add all the extra response headers from the exception. List<Pair<String, List<String>>> headers = new ArrayList<>(); headers.addAll(apiException.getExtraResponseHeaders()); // Include the ApiException's message as a logged key/value pair. if (StringUtils.isNotBlank(ex.getMessage())) messages.add(Pair.of("api_exception_message", ex.getMessage())); return ApiExceptionHandlerListenerResult.handleResponse(errors, messages, headers); } }
@Override public ApiExceptionHandlerListenerResult shouldHandleException(Throwable ex) { SortedApiErrorSet handledErrors = null; List<Pair<String, String>> extraDetailsForLogging = new ArrayList<>(); // Look for exceptions we're supposed to handle. if (isTemporaryProblem(ex, extraDetailsForLogging)) { handledErrors = singletonSortedSetOf(projectApiErrors.getTemporaryServiceProblemApiError()); } else if (ex instanceof ServerHttpStatusCodeException) { handledErrors = processServerHttpStatusCodeException( (ServerHttpStatusCodeException) ex, extraDetailsForLogging ); } else if (ex instanceof ServerUnknownHttpStatusCodeException) { handledErrors = processServerUnknownHttpStatusCodeException( (ServerUnknownHttpStatusCodeException) ex, extraDetailsForLogging ); } if (handledErrors != null) return ApiExceptionHandlerListenerResult.handleResponse(handledErrors, extraDetailsForLogging); // Not an exception we care about - ignore it. return ApiExceptionHandlerListenerResult.ignoreResponse(); }
return ApiExceptionHandlerListenerResult.handleResponse( singletonError(getApiErrorForCircuitBreakerException(cbe)), singletonList(Pair.of("circuit_breaker_id", String.valueOf(cbe.circuitBreakerId))) return ApiExceptionHandlerListenerResult.handleResponse( singletonError(projectApiErrors.getTemporaryServiceProblemApiError()), singletonList(Pair.of( return ApiExceptionHandlerListenerResult.handleResponse( singletonError(projectApiErrors.getTemporaryServiceProblemApiError()), Arrays.asList( return ApiExceptionHandlerListenerResult.handleResponse( singletonError(projectApiErrors.getTemporaryServiceProblemApiError()), singletonList(Pair.of("closed_channel_id", String.valueOf(dsClosedEx.channelId))) ? generateTooLongFrameApiError((TooLongFrameException)ex) : projectApiErrors.getMalformedRequestApiError(); return ApiExceptionHandlerListenerResult.handleResponse( singletonError(errorToUse), withBaseExceptionMessage( Pair.of("cause", "The request exceeded the maximum payload size allowed") ); return ApiExceptionHandlerListenerResult.handleResponse( singletonError(errorToUse), withBaseExceptionMessage( return ApiExceptionHandlerListenerResult.handleResponse(
result = ApiExceptionHandlerListenerResult.handleResponse(handledErrors, extraDetailsForLogging);