Skip to content

Make it possible to pass method and URL to ResponseErrorHandler [SPR-15511] #20070

@spring-projects-issues

Description

@spring-projects-issues

Dmitry Katsubo opened SPR-15511 and commented

There is a need to create a custom exception that contains method (GET, PUT, ...) and URL information in custom ResponseErrorHandler. Currently the only way to add this information to the exception is to catch and re-wrap it into another exception:

RestTemplate restTemplate = new RestTemplate();
restTemplate.setErrorHandler(new MyRestErrorHandler());

String url = "...";
try {
    String response = restTemplate.getForEntity(url, String.class);
} catch (MyRestException e) {
    throw new MyRestUrlException(HttpMethod.GET, url, e);
}

Consider extending ResponseErrorHandler interface so that the signature is:

void handleError(HttpMethod method, URI url, ClientHttpResponse response) throws IOException;

Affects: 4.3.8

Referenced from: commits 805fcc6

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)type: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions