public class CustomHttpErrors
extends java.lang.Object
RetryHttpRequestInitializer
in order to provide
custom errors for failing http calls. This class allows you to specify custom error messages
which match specific error codes and containing strings in the URL. The first matcher to match
the request and response will be used to provide the custom error.
The intended use case here is to examine one of the logs emitted by a failing call made by the RetryHttpRequestInitializer, and then adding a custom error message which matches the URL and code for it.
Usage: See more in CustomHttpErrorsTest.
CustomHttpErrors.Builder builder = new CustomHttpErrors.Builder();
builder.addErrorForCodeAndUrlContains(403,"/tables?", "Custom Error Msg");
CustomHttpErrors customErrors = builder.build();
RetryHttpRequestInitializer initializer = ...
initializer.setCustomErrors(customErrors);
Suggestions for future enhancements to anyone upgrading this file:
Modifier and Type | Class and Description |
---|---|
static class |
CustomHttpErrors.Builder
A Builder which allows building immutable CustomHttpErrors object.
|
static class |
CustomHttpErrors.MatcherAndError
A simple Tuple class for creating a list of HttpResponseMatcher and HttpResponseCustomError to
print for the responses.
|
Modifier and Type | Method and Description |
---|---|
java.lang.String |
getCustomError(org.apache.beam.sdk.extensions.gcp.util.HttpRequestWrapper req,
org.apache.beam.sdk.extensions.gcp.util.HttpResponseWrapper res) |