Tabnine Logo
S3ErrorResponseHandler
Code IndexAdd Tabnine to your IDE (free)

How to use
S3ErrorResponseHandler
in
com.amazonaws.services.s3.internal

Best Java code snippets using com.amazonaws.services.s3.internal.S3ErrorResponseHandler (Showing top 11 results out of 315)

origin: aws/aws-sdk-java

@Override
public AmazonServiceException handle(HttpResponse httpResponse)
    throws XMLStreamException {
  final AmazonServiceException exception = createException(httpResponse);
  exception.setHttpHeaders(httpResponse.getHeaders());
  return exception;
}
origin: aws/aws-sdk-java

  return createExceptionFromHeaders(httpResponse, null);
  if (log.isDebugEnabled())
    log.debug("Failed in parsing the error response : ", ioe);
  return createExceptionFromHeaders(httpResponse, null);
      if (targetDepth == 1
          && !S3ErrorTags.Error.toString().equals(tagName))
        return createExceptionFromHeaders(httpResponse,
            "Unable to parse error response. Error XML Not in proper format."
                + content);
      targetDepth--;
      if (!(hasErrorTagVisited) || targetDepth > 1) {
        return createExceptionFromHeaders(httpResponse,
            "Unable to parse error response. Error XML Not in proper format."
                + content);
        e);
return createExceptionFromHeaders(httpResponse, content);
origin: aws-amplify/aws-sdk-android

return newAmazonS3Exception(errorResponse.getStatusText(), errorResponse);
  log.debug("Failed in reading the error response", ex);
return newAmazonS3Exception(errorResponse.getStatusText(), errorResponse);
final int statusCode = errorResponse.getStatusCode();
ase.setStatusCode(statusCode);
ase.setErrorType(errorTypeOf(statusCode));
ase.setErrorCode(errorCode);
ase.setRequestId(requestId);
  log.debug("Failed in parsing the response as XML: " + content, ex);
return newAmazonS3Exception(content, errorResponse);
origin: aws-amplify/aws-sdk-android

@Test
public void testErrorResponseFromUnparsableXML() throws IOException {
  String response = "<Error>"
      + "<Message>testError";
  ByteArrayInputStream content = new ByteArrayInputStream(response.getBytes(StringUtils.UTF8));
  HttpResponse errorResponse = new HttpResponse.Builder()
      .statusCode(200)
      .content(content)
      .statusText("testError").build();
  S3ErrorResponseHandler handler = new S3ErrorResponseHandler();
  AmazonS3Exception ase = (AmazonS3Exception) handler.handle(errorResponse);
  assertEquals(ase.getStatusCode(), 200);
  assertEquals(ase.getErrorType(), ErrorType.Client);
  assertEquals(ase.getErrorCode(), "200 testError");
}
origin: aws-amplify/aws-sdk-android

/**
 * Used to create an {@link AmazonS3Exception} when we failed to read the
 * error response or parsed the error response as XML.
 */
private AmazonS3Exception newAmazonS3Exception(String errmsg, HttpResponse httpResponse) {
  final AmazonS3Exception ase = new AmazonS3Exception(errmsg);
  final int statusCode = httpResponse.getStatusCode();
  ase.setErrorCode(statusCode + " " + httpResponse.getStatusText());
  ase.setStatusCode(statusCode);
  ase.setErrorType(errorTypeOf(statusCode));
  final Map<String, String> headers = httpResponse.getHeaders();
  ase.setRequestId(headers.get(Headers.REQUEST_ID));
  ase.setExtendedRequestId(headers.get(Headers.EXTENDED_REQUEST_ID));
  ase.setCloudFrontId(headers.get(Headers.CLOUD_FRONT_ID));
  final Map<String, String> additionalDetails = new HashMap<String, String>();
  additionalDetails.put(Headers.S3_BUCKET_REGION,
      headers.get(Headers.S3_BUCKET_REGION));
  ase.setAdditionalDetails(additionalDetails);
  return ase;
}
origin: com.amazonaws/aws-android-sdk-s3

return newAmazonS3Exception(errorResponse.getStatusText(), errorResponse);
  log.debug("Failed in reading the error response", ex);
return newAmazonS3Exception(errorResponse.getStatusText(), errorResponse);
final int statusCode = errorResponse.getStatusCode();
ase.setStatusCode(statusCode);
ase.setErrorType(errorTypeOf(statusCode));
ase.setErrorCode(errorCode);
ase.setRequestId(requestId);
  log.debug("Failed in parsing the response as XML: " + content, ex);
return newAmazonS3Exception(content, errorResponse);
origin: aws-amplify/aws-sdk-android

@Test
public void testHandleErrorResponse() throws IOException {
  String response = "<Error>"
      + "<Message>testError</Message>"
      + "<Code>testCode</Code>"
      + "<RequestId>testId</RequestId>"
      + "<HostId>testHost</HostId>"
      + "</Error>";
  ByteArrayInputStream content = new ByteArrayInputStream(response.getBytes(StringUtils.UTF8));
  HttpResponse errorResponse = new HttpResponse.Builder()
      .statusCode(200)
      .content(content)
      .statusText("testError").build();
  S3ErrorResponseHandler handler = new S3ErrorResponseHandler();
  AmazonS3Exception ase = (AmazonS3Exception) handler.handle(errorResponse);
  assertEquals(ase.getErrorMessage(), "testError");
  assertEquals(ase.getErrorType(), ErrorType.Client);
  assertEquals(ase.getRequestId(), "testId");
  assertEquals(ase.getExtendedRequestId(), "testHost");
  assertEquals(ase.getStatusCode(), 200);
  assertEquals(ase.getErrorCode(), "testCode");
}
origin: com.amazonaws/aws-android-sdk-s3

/**
 * Used to create an {@link AmazonS3Exception} when we failed to read the
 * error response or parsed the error response as XML.
 */
private AmazonS3Exception newAmazonS3Exception(String errmsg, HttpResponse httpResponse) {
  final AmazonS3Exception ase = new AmazonS3Exception(errmsg);
  final int statusCode = httpResponse.getStatusCode();
  ase.setErrorCode(statusCode + " " + httpResponse.getStatusText());
  ase.setStatusCode(statusCode);
  ase.setErrorType(errorTypeOf(statusCode));
  final Map<String, String> headers = httpResponse.getHeaders();
  ase.setRequestId(headers.get(Headers.REQUEST_ID));
  ase.setExtendedRequestId(headers.get(Headers.EXTENDED_REQUEST_ID));
  ase.setCloudFrontId(headers.get(Headers.CLOUD_FRONT_ID));
  final Map<String, String> additionalDetails = new HashMap<String, String>();
  additionalDetails.put(Headers.S3_BUCKET_REGION,
      headers.get(Headers.S3_BUCKET_REGION));
  ase.setAdditionalDetails(additionalDetails);
  return ase;
}
origin: aws-amplify/aws-sdk-android

@Test
public void testHandleErrorResponseWithNoBody() throws IOException {
  HttpResponse errorResponse = new HttpResponse.Builder()
      .statusCode(500)
      .content(null)
      .statusText("testError")
      .header(Headers.REQUEST_ID, "testId")
      .header(Headers.EXTENDED_REQUEST_ID, "extendedId").build();
  S3ErrorResponseHandler handler = new S3ErrorResponseHandler();
  AmazonS3Exception ase = (AmazonS3Exception) handler.handle(errorResponse);
  assertEquals(ase.getErrorMessage(), "testError");
  assertEquals(ase.getErrorType(), ErrorType.Service);
  assertEquals(ase.getRequestId(), "testId");
  assertEquals(ase.getExtendedRequestId(), "extendedId");
  assertEquals(ase.getStatusCode(), 500);
}
origin: Nextdoor/bender

@Override
public AmazonServiceException handle(HttpResponse httpResponse)
    throws XMLStreamException {
  final AmazonServiceException exception = createException(httpResponse);
  exception.setHttpHeaders(httpResponse.getHeaders());
  return exception;
}
origin: Nextdoor/bender

  return createExceptionFromHeaders(httpResponse, null);
  if (log.isDebugEnabled())
    log.debug("Failed in parsing the error response : ", ioe);
  return createExceptionFromHeaders(httpResponse, null);
      if (targetDepth == 1
          && !S3ErrorTags.Error.toString().equals(tagName))
        return createExceptionFromHeaders(httpResponse,
            "Unable to parse error response. Error XML Not in proper format."
                + content);
      targetDepth--;
      if (!(hasErrorTagVisited) || targetDepth > 1) {
        return createExceptionFromHeaders(httpResponse,
            "Unable to parse error response. Error XML Not in proper format."
                + content);
        e);
return createExceptionFromHeaders(httpResponse, content);
com.amazonaws.services.s3.internalS3ErrorResponseHandler

Javadoc

Response handler for S3 error responses. S3 error responses are different from other AWS error responses in a few ways. Most error responses will contain an XML body, but not all (ex: error responses to HEAD requests will not), so this error handler has to account for that. The actual XML error response body is slightly different than other services like SimpleDB or EC2 and some information isn't explicitly represented in the XML error response body (ex: error type/fault information) so it has to be inferred from other parts of the error response.

Most used methods

  • createException
  • createExceptionFromHeaders
  • errorTypeOf
    Returns the AWS error type information by looking at the HTTP status code in the error response. S3
  • newAmazonS3Exception
    Used to create an AmazonS3Exception when we failed to read the error response or parsed the error re
  • <init>
  • handle

Popular in Java

  • Reactive rest calls using spring rest template
  • scheduleAtFixedRate (ScheduledExecutorService)
  • requestLocationUpdates (LocationManager)
  • notifyDataSetChanged (ArrayAdapter)
  • FileNotFoundException (java.io)
    Thrown when a file specified by a program cannot be found.
  • FileReader (java.io)
    A specialized Reader that reads from a file in the file system. All read requests made by calling me
  • Enumeration (java.util)
    A legacy iteration interface.New code should use Iterator instead. Iterator replaces the enumeration
  • Reference (javax.naming)
  • SSLHandshakeException (javax.net.ssl)
    The exception that is thrown when a handshake could not be completed successfully.
  • Response (javax.ws.rs.core)
    Defines the contract between a returned instance and the runtime when an application needs to provid
  • Top Vim plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now