@Test public void systemError() throws Exception { thrown.expect(RetryableException.class); thrown.expectMessage("UltraDNS#networkStatus() failed with error 9999: System Error"); throw errors.decode("UltraDNS#networkStatus()", errorResponse(format(FAULT_TEMPLATE, SYSTEM_ERROR, "System Error"))); }
@Override public Exception decode(String methodKey, Response response) { try { response = bufferResponse(response); UltraDNSError error = UltraDNSError.class.cast(decoder.decode(response, UltraDNSError.class)); if (error == null) { return FeignException.errorStatus(methodKey, response); } String message = format("%s failed", methodKey); if (error.code != -1) { message = format("%s with error %s", message, error.code); } if (error.description != null) { message = format("%s: %s", message, error.description); } if (error.code == UltraDNSException.SYSTEM_ERROR) { return new RetryableException(message, null); } return new UltraDNSException(message, error.code); } catch (IOException ignored) { return FeignException.errorStatus(methodKey, response); } catch (Exception propagate) { return propagate; } }
UltraDNSErrorDecoder implements ErrorDecoder { @Override public Exception decode(String methodKey, Response response) { try { response = bufferResponse(response); UltraDNSError error = UltraDNSError.class.cast(decoder.decode(response, UltraDNSError.class)); if (error == null) { return FeignException.errorStatus(methodKey, response); } String message = format("%s failed", methodKey); if (error.code != -1) { message = format("%s with error %s", message, error.code); } if (error.description != null) { message = format("%s: %s", message, error.description); } if (error.code == UltraDNSException.SYSTEM_ERROR) { return new RetryableException(message, null); } return new UltraDNSException(message, error.code); } catch (IOException ignored) { return FeignException.errorStatus(methodKey, response); } catch (Exception propagate) { return propagate; } } }
UltraDNSErrorDecoder implements ErrorDecoder { @Override public Exception decode(String methodKey, Response response) { try { response = bufferResponse(response); UltraDNSError error = UltraDNSError.class.cast(decoder.decode(response, UltraDNSError.class)); if (error == null) { return FeignException.errorStatus(methodKey, response); } String message = format("%s failed", methodKey); if (error.code != -1) { message = format("%s with error %s", message, error.code); } if (error.description != null) { message = format("%s: %s", message, error.description); } if (error.code == UltraDNSException.SYSTEM_ERROR) { return new RetryableException(message, null); } return new UltraDNSException(message, error.code); } catch (IOException ignored) { return FeignException.errorStatus(methodKey, response); } catch (Exception propagate) { return propagate; } } UltraDNSErrorDecoder(Decoder decoder); }
UltraDNSErrorDecoder implements ErrorDecoder { @Override public Exception decode(String methodKey, Response response) { try { response = bufferResponse(response); UltraDNSError error = UltraDNSError.class.cast(decoder.decode(response, UltraDNSError.class)); if (error == null) { return FeignException.errorStatus(methodKey, response); } String message = format("%s failed", methodKey); if (error.code != -1) { message = format("%s with error %s", message, error.code); } if (error.description != null) { message = format("%s: %s", message, error.description); } if (error.code == UltraDNSException.SYSTEM_ERROR) { return new RetryableException(message, null); } return new UltraDNSException(message, error.code); } catch (IOException ignored) { return FeignException.errorStatus(methodKey, response); } catch (Exception propagate) { return propagate; } } UltraDNSErrorDecoder(Decoder decoder); @Override Exception decode(String methodKey, Response response); }
UltraDNSErrorDecoder implements ErrorDecoder { @Override public Exception decode(String methodKey, Response response) { try { response = bufferResponse(response); UltraDNSError error = UltraDNSError.class.cast(decoder.decode(response, UltraDNSError.class)); if (error == null) { return FeignException.errorStatus(methodKey, response); } String message = format("%s failed", methodKey); if (error.code != -1) { message = format("%s with error %s", message, error.code); } if (error.description != null) { message = format("%s: %s", message, error.description); } if (error.code == UltraDNSException.SYSTEM_ERROR) { return new RetryableException(message, null); } return new UltraDNSException(message, error.code); } catch (IOException ignored) { return FeignException.errorStatus(methodKey, response); } catch (Exception propagate) { return propagate; } } UltraDNSErrorDecoder(Decoder decoder); @Override Exception decode(String methodKey, Response response);  }