ResponseErrorHandler provides access to URI and method
Issue: SPR-15511
This commit is contained in:
@@ -539,7 +539,7 @@ public class AsyncRestTemplate extends org.springframework.http.client.support.I
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
getErrorHandler().handleError(response);
|
||||
getErrorHandler().handleError(url, method, response);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -17,7 +17,9 @@
|
||||
package org.springframework.web.client;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.client.ClientHttpResponse;
|
||||
|
||||
/**
|
||||
@@ -48,4 +50,17 @@ public interface ResponseErrorHandler {
|
||||
*/
|
||||
void handleError(ClientHttpResponse response) throws IOException;
|
||||
|
||||
/**
|
||||
* Alternative to {@link #handleError(ClientHttpResponse)} with extra
|
||||
* information providing access to the request URL and HTTP method.
|
||||
* @param url the request URL
|
||||
* @param method the HTTP method
|
||||
* @param response the response with the error
|
||||
* @throws IOException in case of I/O errors
|
||||
* @since 5.0
|
||||
*/
|
||||
default void handleError(URI url, HttpMethod method, ClientHttpResponse response) throws IOException {
|
||||
handleError(response);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -726,7 +726,7 @@ public class RestTemplate extends InterceptingHttpAccessor implements RestOperat
|
||||
}
|
||||
}
|
||||
if (hasError) {
|
||||
errorHandler.handleError(response);
|
||||
errorHandler.handleError(url, method, response);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user