amazonka
amazonka copied to clipboard
possible to extract response status generically?
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.
+1 to have amazonka generate HasStatus instances
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
@ababkin Currently no, there is no overloaded mechanism for extracting the status.
@axman6 Yes, that seems like a good option.
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.
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.