micronaut-projects / micronaut-core

Micronaut Application Framework
http://micronaut.io
Apache License 2.0
6.09k stars 1.07k forks source link

Declarative http client - requested url on failure #2240

Open schrek1 opened 5 years ago

schrek1 commented 5 years ago

Hello there it isn't possible obtain called url from declarative client when some error occurred. It throws exception, but requested url is not contained in the throwed exception. I think it can be good feature for better tracing.

ashwini-desai commented 5 years ago

@graemerocher I am thinking of attempting this. Do you think this should be done for both declarative and non-declarative client?

If yes, I was thinking of accepting request URI as a constructor argument in HttpClientResponseException class and then in getMessage method, prepend the exception message with request URI. If it is not added in HttpClientResponseException, it cannot be enforced. Does this approach seem right?

graemerocher commented 5 years ago

So I wonder where this ends. This issue is about the request URI but maybe somebody else needs the whole request? If the response exception is going to be modified to take the request URI we may as well allow access to the entire original request

schrek1 commented 5 years ago

We solved finally by HttpClientFilter, which can handle incoming request and process delivered response.

ashwini-desai commented 5 years ago

@graemerocher sounds right. Raising a PR by passing request to HttpClientResponseException and printing request's path for now.