Search in sources :

Example 1 with DefaultFailedExecutionContext

use of software.amazon.awssdk.core.internal.interceptor.DefaultFailedExecutionContext in project aws-sdk-java-v2 by aws.

the class ExecutionInterceptorChain method modifyException.

public DefaultFailedExecutionContext modifyException(DefaultFailedExecutionContext context, ExecutionAttributes executionAttributes) {
    DefaultFailedExecutionContext result = context;
    for (int i = interceptors.size() - 1; i >= 0; i--) {
        Throwable interceptorResult = interceptors.get(i).modifyException(result, executionAttributes);
        validateInterceptorResult(result.exception(), interceptorResult, interceptors.get(i), "modifyException");
        result = result.copy(b -> b.exception(interceptorResult));
    }
    return result;
}
Also used : SdkHttpResponse(software.amazon.awssdk.http.SdkHttpResponse) Validate(software.amazon.awssdk.utils.Validate) SdkHttpRequest(software.amazon.awssdk.http.SdkHttpRequest) Logger(software.amazon.awssdk.utils.Logger) Publisher(org.reactivestreams.Publisher) DefaultFailedExecutionContext(software.amazon.awssdk.core.internal.interceptor.DefaultFailedExecutionContext) ContentStreamProvider(software.amazon.awssdk.http.ContentStreamProvider) ByteBuffer(java.nio.ByteBuffer) ArrayList(java.util.ArrayList) Objects(java.util.Objects) Consumer(java.util.function.Consumer) List(java.util.List) SdkProtectedApi(software.amazon.awssdk.annotations.SdkProtectedApi) AsyncRequestBody(software.amazon.awssdk.core.async.AsyncRequestBody) Optional(java.util.Optional) SdkResponse(software.amazon.awssdk.core.SdkResponse) RequestBody(software.amazon.awssdk.core.sync.RequestBody) SdkHttpFullRequest(software.amazon.awssdk.http.SdkHttpFullRequest) SdkRequest(software.amazon.awssdk.core.SdkRequest) InputStream(java.io.InputStream) DefaultFailedExecutionContext(software.amazon.awssdk.core.internal.interceptor.DefaultFailedExecutionContext)

Example 2 with DefaultFailedExecutionContext

use of software.amazon.awssdk.core.internal.interceptor.DefaultFailedExecutionContext in project aws-sdk-java-v2 by aws.

the class HelpfulUnknownHostExceptionInterceptorTest method modifyException.

private Throwable modifyException(Throwable throwable, Region clientRegion, String serviceEndpointPrefix) {
    SdkRequest sdkRequest = Mockito.mock(SdkRequest.class);
    DefaultFailedExecutionContext context = DefaultFailedExecutionContext.builder().interceptorContext(InterceptorContext.builder().request(sdkRequest).build()).exception(throwable).build();
    ExecutionAttributes executionAttributes = new ExecutionAttributes().putAttribute(AwsExecutionAttribute.AWS_REGION, clientRegion).putAttribute(AwsExecutionAttribute.ENDPOINT_PREFIX, serviceEndpointPrefix);
    return INTERCEPTOR.modifyException(context, executionAttributes);
}
Also used : ExecutionAttributes(software.amazon.awssdk.core.interceptor.ExecutionAttributes) SdkRequest(software.amazon.awssdk.core.SdkRequest) DefaultFailedExecutionContext(software.amazon.awssdk.core.internal.interceptor.DefaultFailedExecutionContext)

Aggregations

SdkRequest (software.amazon.awssdk.core.SdkRequest)2 DefaultFailedExecutionContext (software.amazon.awssdk.core.internal.interceptor.DefaultFailedExecutionContext)2 InputStream (java.io.InputStream)1 ByteBuffer (java.nio.ByteBuffer)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Objects (java.util.Objects)1 Optional (java.util.Optional)1 Consumer (java.util.function.Consumer)1 Publisher (org.reactivestreams.Publisher)1 SdkProtectedApi (software.amazon.awssdk.annotations.SdkProtectedApi)1 SdkResponse (software.amazon.awssdk.core.SdkResponse)1 AsyncRequestBody (software.amazon.awssdk.core.async.AsyncRequestBody)1 ExecutionAttributes (software.amazon.awssdk.core.interceptor.ExecutionAttributes)1 RequestBody (software.amazon.awssdk.core.sync.RequestBody)1 ContentStreamProvider (software.amazon.awssdk.http.ContentStreamProvider)1 SdkHttpFullRequest (software.amazon.awssdk.http.SdkHttpFullRequest)1 SdkHttpRequest (software.amazon.awssdk.http.SdkHttpRequest)1 SdkHttpResponse (software.amazon.awssdk.http.SdkHttpResponse)1 Logger (software.amazon.awssdk.utils.Logger)1