@Test public void internalError() throws Exception { thrown.expect(RetryableException.class); thrown.expectMessage("Route53.zones() failed with error InternalError"); Response response = response("<Response xmlns=\"https: + " <Errors>\n" + " <Error>\n" + " <Code>InternalError</Code>\n" + " </Error>\n" + " </Errors>\n" + " <RequestID>dc94a37b0-e297-4ab7-83c8-791a0fc8f613</RequestID>\n" + "</Response>"); throw errors.decode("Route53.zones()", response); }
@Override public Exception decode(String methodKey, Response response) { try { if ("Route53#changeResourceRecordSets(String,List)".equals(methodKey)) { @SuppressWarnings("unchecked") List<String> messages = List.class.cast(decoder.decode(response, LIST_STRING)); return new InvalidChangeBatchException(methodKey, messages); } Route53Error error = Route53Error.class.cast(decoder.decode(response, Route53Error.class)); if (error == null) { return FeignException.errorStatus(methodKey, response); } String message = format("%s failed with error %s", methodKey, error.code); if (error.message != null) { message = format("%s: %s", message, error.message); } if ("RequestExpired".equals(error.code) || "InternalError".equals(error.code) || "InternalFailure".equals(error.code)) { return new RetryableException(message, null); } else if ("Throttling".equals(error.code) || "PriorRequestNotComplete".equals(error.code)) { return new RetryableException(message, new Date(currentTimeMillis() + 1000)); } else if (error.code.startsWith("NoSuch")) { } return new Route53Exception(message, error.code); } catch (IOException e) { return FeignException.errorStatus(methodKey, response); } }
Route53ErrorDecoder implements ErrorDecoder { @Override public Exception decode(String methodKey, Response response) { try { if ("Route53#changeResourceRecordSets(String,List)".equals(methodKey)) { @SuppressWarnings("unchecked") List<String> messages = List.class.cast(decoder.decode(response, LIST_STRING)); return new InvalidChangeBatchException(methodKey, messages); } Route53Error error = Route53Error.class.cast(decoder.decode(response, Route53Error.class)); if (error == null) { return FeignException.errorStatus(methodKey, response); } String message = format("%s failed with error %s", methodKey, error.code); if (error.message != null) { message = format("%s: %s", message, error.message); } if ("RequestExpired".equals(error.code) || "InternalError".equals(error.code) || "InternalFailure".equals(error.code)) { return new RetryableException(message, null); } else if ("Throttling".equals(error.code) || "PriorRequestNotComplete".equals(error.code)) { return new RetryableException(message, new Date(currentTimeMillis() + 1000)); } else if (error.code.startsWith("NoSuch")) { } return new Route53Exception(message, error.code); } catch (IOException e) { return FeignException.errorStatus(methodKey, response); } } }
Route53ErrorDecoder implements ErrorDecoder { @Override public Exception decode(String methodKey, Response response) { try { if ("Route53#changeResourceRecordSets(String,List)".equals(methodKey)) { @SuppressWarnings("unchecked") List<String> messages = List.class.cast(decoder.decode(response, LIST_STRING)); return new InvalidChangeBatchException(methodKey, messages); } Route53Error error = Route53Error.class.cast(decoder.decode(response, Route53Error.class)); if (error == null) { return FeignException.errorStatus(methodKey, response); } String message = format("%s failed with error %s", methodKey, error.code); if (error.message != null) { message = format("%s: %s", message, error.message); } if ("RequestExpired".equals(error.code) || "InternalError".equals(error.code) || "InternalFailure".equals(error.code)) { return new RetryableException(message, null); } else if ("Throttling".equals(error.code) || "PriorRequestNotComplete".equals(error.code)) { return new RetryableException(message, new Date(currentTimeMillis() + 1000)); } else if (error.code.startsWith("NoSuch")) { } return new Route53Exception(message, error.code); } catch (IOException e) { return FeignException.errorStatus(methodKey, response); } } Route53ErrorDecoder(Decoder decoder); }
Route53ErrorDecoder implements ErrorDecoder { @Override public Exception decode(String methodKey, Response response) { try { if ("Route53#changeResourceRecordSets(String,List)".equals(methodKey)) { @SuppressWarnings("unchecked") List<String> messages = List.class.cast(decoder.decode(response, LIST_STRING)); return new InvalidChangeBatchException(methodKey, messages); } Route53Error error = Route53Error.class.cast(decoder.decode(response, Route53Error.class)); if (error == null) { return FeignException.errorStatus(methodKey, response); } String message = format("%s failed with error %s", methodKey, error.code); if (error.message != null) { message = format("%s: %s", message, error.message); } if ("RequestExpired".equals(error.code) || "InternalError".equals(error.code) || "InternalFailure".equals(error.code)) { return new RetryableException(message, null); } else if ("Throttling".equals(error.code) || "PriorRequestNotComplete".equals(error.code)) { return new RetryableException(message, new Date(currentTimeMillis() + 1000)); } else if (error.code.startsWith("NoSuch")) { } return new Route53Exception(message, error.code); } catch (IOException e) { return FeignException.errorStatus(methodKey, response); } } Route53ErrorDecoder(Decoder decoder); @Override Exception decode(String methodKey, Response response); }
Route53ErrorDecoder implements ErrorDecoder { @Override public Exception decode(String methodKey, Response response) { try { if ("Route53#changeResourceRecordSets(String,List)".equals(methodKey)) { @SuppressWarnings("unchecked") List<String> messages = List.class.cast(decoder.decode(response, LIST_STRING)); return new InvalidChangeBatchException(methodKey, messages); } Route53Error error = Route53Error.class.cast(decoder.decode(response, Route53Error.class)); if (error == null) { return FeignException.errorStatus(methodKey, response); } String message = format("%s failed with error %s", methodKey, error.code); if (error.message != null) { message = format("%s: %s", message, error.message); } if ("RequestExpired".equals(error.code) || "InternalError".equals(error.code) || "InternalFailure".equals(error.code)) { return new RetryableException(message, null); } else if ("Throttling".equals(error.code) || "PriorRequestNotComplete".equals(error.code)) { return new RetryableException(message, new Date(currentTimeMillis() + 1000)); } else if (error.code.startsWith("NoSuch")) { } return new Route53Exception(message, error.code); } catch (IOException e) { return FeignException.errorStatus(methodKey, response); } } Route53ErrorDecoder(Decoder decoder); @Override Exception decode(String methodKey, Response response);  }