Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extract common interface of HttpStatusCodeException and UnknownHttpStatusCodeException [SPR-13928] #18500

Closed
spring-projects-issues opened this issue Feb 8, 2016 · 1 comment
Assignees
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: task A general task
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

spring-projects-issues commented Feb 8, 2016

James Howe opened SPR-13928 and commented

Extract the common methods so that they can be used without determining the specific type.
In many cases, handling for an HTTP response would be identical, regardless of whether spring knows about the specific status code.

In particular, I would like to access getResponseHeaders() and getResponseBodyAsString(), but see no reason why an HttpStatusCodeException couldn't also have a getRawStatusCode() method.

For example:

try {
  // some RestTemplate code
}
catch (HttpStatusCodeException | UnknownHttpStatusCodeException ex) {
  // log and/or forward response
  response.setStatus(ex.getRawStatusCode());
  response.setHeaders(ex.getResponseHeaders());
}
catch (ResourceAccessException ex) {
  // retry
}

Referenced from: commits b11d345

@spring-projects-issues
Copy link
Collaborator Author

spring-projects-issues commented Feb 10, 2016

Rossen Stoyanchev commented

There is now a common base class RestClientResponseException.

@spring-projects-issues spring-projects-issues added in: web Issues in web modules (web, webmvc, webflux, websocket) type: task A general task labels Jan 11, 2019
@spring-projects-issues spring-projects-issues added this to the 4.3 RC1 milestone Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: task A general task
Projects
None yet
Development

No branches or pull requests

2 participants