1515 */
1616package feign .codec ;
1717
18- import java .lang .reflect .Type ;
1918import java .text .DateFormat ;
2019import java .text .ParseException ;
2120import java .text .SimpleDateFormat ;
3534import static java .util .concurrent .TimeUnit .SECONDS ;
3635
3736/**
38- * Allows you to massage an exception into a application-specific one, or
39- * fallback to a default value. Falling back to null on
40- * {@link Response#status() status 404}, or converting out to a throttle
37+ * Allows you to massage an exception into a application-specific one. Converting out to a throttle
4138 * exception are examples of this in use.
4239 * <br>
4340 * Ex.
4441 * <br>
4542 * <pre>
4643 * class IllegalArgumentExceptionOn404Decoder extends ErrorDecoder {
4744 *
48- * @Override
49- * public Object decode(String methodKey, Response response, Type<?> type) throws Throwable {
45+ * @Override
46+ * public Exception decode(String methodKey, Response response) {
5047 * if (response.status() == 404)
5148 * throw new IllegalArgumentException("zone not found");
52- * return ErrorDecoder.DEFAULT.decode(request, response, type );
53- * }
49+ * return ErrorDecoder.DEFAULT.decode(methodKey, request, response );
50+ * }
5451 *
5552 * }
5653 * </pre>
@@ -59,33 +56,29 @@ public interface ErrorDecoder {
5956
6057 /**
6158 * Implement this method in order to decode an HTTP {@link Response} when
62- * {@link Response#status()} is not in the 2xx range. Please raise
63- * application-specific exceptions or return fallback values where possible.
64- * If your exception is retryable, wrap or subclass
65- * {@link RetryableException}
59+ * {@link Response#status()} is not in the 2xx range. Please raise application-specific exceptions where possible.
60+ * If your exception is retryable, wrap or subclass {@link RetryableException}
6661 *
6762 * @param methodKey {@link feign.Feign#configKey} of the java method that invoked the request. ex. {@code IAM#getUser()}
6863 * @param response HTTP response where {@link Response#status() status} is greater than or equal to {@code 300}.
69- * @param type Target object type.
70- * @return instance of {@code type}
71- * @throws Throwable IOException, if there was a network error reading the
72- * response or an application-specific exception decoded by the
73- * implementation. If the throwable is retryable, it should be
74- * wrapped, or a subtype of {@link RetryableException}
64+ * @return Exception IOException, if there was a network error reading the
65+ * response or an application-specific exception decoded by the
66+ * implementation. If the throwable is retryable, it should be
67+ * wrapped, or a subtype of {@link RetryableException}
7568 */
76- public Object decode (String methodKey , Response response , Type type ) throws Throwable ;
69+ public Exception decode (String methodKey , Response response ) ;
7770
7871 public static final ErrorDecoder DEFAULT = new ErrorDecoder () {
7972
8073 private final RetryAfterDecoder retryAfterDecoder = new RetryAfterDecoder ();
8174
8275 @ Override
83- public Object decode (String methodKey , Response response , Type type ) throws Throwable {
76+ public Exception decode (String methodKey , Response response ) {
8477 FeignException exception = errorStatus (methodKey , response );
8578 Date retryAfter = retryAfterDecoder .apply (firstOrNull (response .headers (), RETRY_AFTER ));
8679 if (retryAfter != null )
87- throw new RetryableException (exception .getMessage (), exception , retryAfter );
88- throw exception ;
80+ return new RetryableException (exception .getMessage (), exception , retryAfter );
81+ return exception ;
8982 }
9083
9184 private <T > T firstOrNull (Map <String , Collection <T >> map , String key ) {
0 commit comments