amazonka icon indicating copy to clipboard operation
amazonka copied to clipboard

possible to extract response status generically?

Open ababkin opened this issue 7 years ago • 5 comments

One currently needs to extract status code in the following fashion:

r <- send $ <some request>
case r^.srsResponseStatus of
...

I was curious whether there is a way to extract the status without the request specific lens. This would allow for a more generic error handling code. I guess I could do this by defining something like a HasStatus type class and making instances for all requests i use, but I hope there is an easier way to do this with amazonka.

ababkin avatar Dec 21 '16 18:12 ababkin

+1 to have amazonka generate HasStatus instances

joehillen avatar Dec 22 '16 22:12 joehillen

Is there any reason this couldn't be a lens that needs to be defined in the AWSRequest class? Add

rsStatus :: Lens (Rs a) Int

axman6 avatar Dec 23 '16 02:12 axman6

@ababkin Currently no, there is no overloaded mechanism for extracting the status.

@axman6 Yes, that seems like a good option.

brendanhay avatar Dec 23 '16 07:12 brendanhay

This looks like a good combination of easy/useful that I will optimistically assign it to the 2.0 Milestone. If I can't work out the generator code, I'll punt it to post-2.0.

endgame avatar Oct 03 '21 21:10 endgame

Let's delay doing this and think about solving #180 instead - that will provide us with a canonical way to get the response code for any response, as well as solve the problem with nullary responses. Better not to introduce a feature and then immediately break it.

endgame avatar Oct 04 '21 02:10 endgame