@SuppressWarnings("unchecked") private void createErrorUnmarshallers() { for (JsonErrorShapeMetadata errorMetadata : metadata.getErrorShapeMetadata()) { errorUnmarshallers.add(new JsonErrorUnmarshaller( (Class<? extends AmazonServiceException>) errorMetadata.getModeledClass(), errorMetadata.getErrorCode())); } errorUnmarshallers.add(new JsonErrorUnmarshaller( (Class<? extends AmazonServiceException>) metadata.getBaseServiceExceptionClass(), null)); }
@Override public AmazonServiceException unmarshall(JsonErrorResponse error) throws Exception { DuplicateProviderException e = (DuplicateProviderException) super.unmarshall(error); e.setErrorCode("DuplicateProviderException"); return e; } }
private AmazonServiceException runErrorUnmarshallers(JsonErrorResponse error) throws Exception { /* * We need to select which exception unmarshaller is the correct one to * use from all the possible exceptions this operation can throw. * Currently we rely on JsonErrorUnmarshaller.match(...) method which * checks for the error type parsed either from response headers or the * content. */ for (JsonErrorUnmarshaller unmarshaller : unmarshallerList) { if (unmarshaller.match(error)) { return unmarshaller.unmarshall(error); } } return null; }
private AmazonServiceException unmarshallException(String errorCode, JsonContent jsonContent) { for (JsonErrorUnmarshaller unmarshaller : unmarshallers) { if (unmarshaller.matchErrorCode(errorCode)) { try { return unmarshaller.unmarshall(jsonContent.getJsonNode()); } catch (Exception e) { LOG.info("Unable to unmarshall exception content", e); return null; } } } return null; }
/** * Subclass should override the match(String, JSONObject) method to indicate * whether it represents the given error type, and unmarshall(JSONObject) * should never return null. */ @Override public AmazonServiceException unmarshall(JsonErrorResponse error) throws Exception { String message = error.getMessage(); String errorCode = error.getErrorCode(); if ((null == message || message.isEmpty()) && (null == errorCode || errorCode.isEmpty())) { /** * Trigger the catch block in AmazonHttpClient.handleErrorResponse * to handle 413 and 503 errors */ throw new AmazonClientException( "Neither error message nor error code is found in the error response payload."); } else { AmazonServiceException ase = newException(message); ase.setErrorCode(errorCode); return ase; } }
/** * Subclass should override the match(String, JSONObject) method to indicate * whether it represents the given error type, and unmarshall(JSONObject) * should never return null. */ @Override public AmazonServiceException unmarshall(JsonErrorResponse error) throws Exception { String message = error.getMessage(); String errorCode = error.getErrorCode(); if ((null == message || message.isEmpty()) && (null == errorCode || errorCode.isEmpty())) { /** * Trigger the catch block in AmazonHttpClient.handleErrorResponse * to handle 413 and 503 errors */ throw new AmazonClientException( "Neither error message nor error code is found in the error response payload."); } else { AmazonServiceException ase = newException(message); ase.setErrorCode(errorCode); return ase; } }
@Override public AmazonServiceException unmarshall(JsonErrorResponse error) throws Exception { ItemCollectionSizeLimitExceededException e = (ItemCollectionSizeLimitExceededException) super .unmarshall(error); e.setErrorCode("ItemCollectionSizeLimitExceededException"); return e; } }
private void init() { jsonErrorUnmarshallers = new ArrayList<JsonErrorUnmarshaller>(); jsonErrorUnmarshallers.add(new BadRequestExceptionUnmarshaller()); jsonErrorUnmarshallers.add(new JsonErrorUnmarshaller()); // calling this.setEndPoint(...) will also modify the signer accordingly this.setEndpoint("mobileanalytics.us-east-1.amazonaws.com"); this.endpointPrefix = "mobileanalytics"; HandlerChainFactory chainFactory = new HandlerChainFactory(); requestHandler2s.addAll(chainFactory.newRequestHandlerChain( "/com/amazonaws/services/pinpointanalytics/request.handlers")); requestHandler2s.addAll(chainFactory.newRequestHandler2Chain( "/com/amazonaws/services/pinpointanalytics/request.handler2s")); }
private AmazonServiceException runErrorUnmarshallers(JsonErrorResponse error) throws Exception { /* * We need to select which exception unmarshaller is the correct one to * use from all the possible exceptions this operation can throw. * Currently we rely on JsonErrorUnmarshaller.match(...) method which * checks for the error type parsed either from response headers or the * content. */ for (JsonErrorUnmarshaller unmarshaller : unmarshallerList) { if (unmarshaller.match(error)) { return unmarshaller.unmarshall(error); } } return null; }
/** * Subclass should override the match(String, JSONObject) method to indicate * whether it represents the given error type, and unmarshall(JSONObject) * should never return null. */ @Override public AmazonServiceException unmarshall(JsonErrorResponse error) throws Exception { String message = error.getMessage(); String errorCode = error.getErrorCode(); if ((null == message || message.isEmpty()) && (null == errorCode || errorCode.isEmpty())) { /** * Trigger the catch block in AmazonHttpClient.handleErrorResponse * to handle 413 and 503 errors */ throw new AmazonClientException( "Neither error message nor error code is found in the error response payload."); } else { AmazonServiceException ase = newException(message); ase.setErrorCode(errorCode); return ase; } }
@Override public AmazonServiceException unmarshall(JsonErrorResponse error) throws Exception { ThrottlingException e = (ThrottlingException) super.unmarshall(error); e.setErrorCode("ThrottlingException"); return e; } }
private void init() { jsonErrorUnmarshallers = new ArrayList<JsonErrorUnmarshaller>(); jsonErrorUnmarshallers.add(new BadRequestExceptionUnmarshaller()); jsonErrorUnmarshallers.add(new JsonErrorUnmarshaller()); // calling this.setEndPoint(...) will also modify the signer accordingly this.setEndpoint("mobileanalytics.us-east-1.amazonaws.com"); this.endpointPrefix = "mobileanalytics"; HandlerChainFactory chainFactory = new HandlerChainFactory(); requestHandler2s.addAll(chainFactory.newRequestHandlerChain( "/com/amazonaws/services/mobileanalytics/request.handlers")); requestHandler2s.addAll(chainFactory.newRequestHandler2Chain( "/com/amazonaws/services/mobileanalytics/request.handler2s")); }
private AmazonServiceException runErrorUnmarshallers(JsonErrorResponse error) throws Exception { /* * We need to select which exception unmarshaller is the correct one to * use from all the possible exceptions this operation can throw. * Currently we rely on JsonErrorUnmarshaller.match(...) method which * checks for the error type parsed either from response headers or the * content. */ for (JsonErrorUnmarshaller unmarshaller : unmarshallerList) { if (unmarshaller.match(error)) { return unmarshaller.unmarshall(error); } } return null; }
@Override public AmazonServiceException unmarshall(JsonErrorResponse error) throws Exception { InvalidSsmlException e = (InvalidSsmlException) super.unmarshall(error); e.setErrorCode("InvalidSsmlException"); return e; } }
@SuppressWarnings("unchecked") private void createErrorUnmarshallers() { for (JsonErrorShapeMetadata errorMetadata : metadata.getErrorShapeMetadata()) { errorUnmarshallers.add(new JsonErrorUnmarshaller( (Class<? extends AmazonServiceException>) errorMetadata.getModeledClass(), errorMetadata.getErrorCode())); } errorUnmarshallers.add(new JsonErrorUnmarshaller( (Class<? extends AmazonServiceException>) metadata.getBaseServiceExceptionClass(), null)); }
private AmazonServiceException runErrorUnmarshallers(HttpClientResponse<ByteBuf> errorResponse, JSONObject json, String errorTypeFromHeader) { /* * We need to select which exception unmarshaller is the correct one to * use from all the possible exceptions this operation can throw. * Currently we rely on JsonErrorUnmarshaller.match(...) method which * checks for the error type parsed either from response headers or the * content. */ try { for (JsonErrorUnmarshaller unmarshaller : unmarshallerList) { if (unmarshaller.match(errorTypeFromHeader, json)) { AmazonServiceException ase = unmarshaller.unmarshall(json); ase.setStatusCode(errorResponse.getStatus().code()); return ase; } } return null; } catch (Exception e) { throw new RuntimeException(e); } }
@Override public AmazonServiceException unmarshall(JsonErrorResponse error) throws Exception { InvalidStateTransitionException e = (InvalidStateTransitionException) super .unmarshall(error); e.setErrorCode("InvalidStateTransitionException"); return e; } }
private void init() { jsonErrorUnmarshallers = new ArrayList<JsonErrorUnmarshaller>(); jsonErrorUnmarshallers.add(new InvalidArgumentExceptionUnmarshaller()); jsonErrorUnmarshallers.add(new ResourceNotFoundExceptionUnmarshaller()); jsonErrorUnmarshallers.add(new ServiceUnavailableExceptionUnmarshaller()); jsonErrorUnmarshallers.add(new JsonErrorUnmarshaller()); // calling this.setEndPoint(...) will also modify the signer accordingly this.setEndpoint("firehose.us-east-1.amazonaws.com"); this.endpointPrefix = "firehose"; HandlerChainFactory chainFactory = new HandlerChainFactory(); requestHandler2s.addAll(chainFactory.newRequestHandlerChain( "/com/amazonaws/services/kinesisfirehose/request.handlers")); requestHandler2s.addAll(chainFactory.newRequestHandler2Chain( "/com/amazonaws/services/kinesisfirehose/request.handler2s")); }
@Override public AmazonServiceException unmarshall(JsonErrorResponse error) throws Exception { RequestEntityTooLargeException e = (RequestEntityTooLargeException) super.unmarshall(error); e.setErrorCode("RequestEntityTooLargeException"); return e; } }
private void init() { jsonErrorUnmarshallers = new ArrayList<JsonErrorUnmarshaller>(); jsonErrorUnmarshallers.add(new InternalServerExceptionUnmarshaller()); jsonErrorUnmarshallers.add(new InvalidInputExceptionUnmarshaller()); jsonErrorUnmarshallers.add(new LimitExceededExceptionUnmarshaller()); jsonErrorUnmarshallers.add(new PredictorNotMountedExceptionUnmarshaller()); jsonErrorUnmarshallers.add(new ResourceNotFoundExceptionUnmarshaller()); jsonErrorUnmarshallers.add(new JsonErrorUnmarshaller()); // calling this.setEndPoint(...) will also modify the signer accordingly this.setEndpoint("machinelearning.us-east-1.amazonaws.com"); this.endpointPrefix = "machinelearning"; HandlerChainFactory chainFactory = new HandlerChainFactory(); requestHandler2s.addAll(chainFactory.newRequestHandlerChain( "/com/amazonaws/services/machinelearning/request.handlers")); requestHandler2s.addAll(chainFactory.newRequestHandler2Chain( "/com/amazonaws/services/machinelearning/request.handler2s")); }