Better Handling of HTTPResponseError with json + Tests#756
Better Handling of HTTPResponseError with json + Tests#756designatednerd merged 2 commits intomasterfrom
HTTPResponseError with json + Tests#756Conversation
|
@jordanhbuiltbyhq Mind taking a look at this to make sure this is the behavior you were looking for? |
|
This is lovely, thanks! Any expectation for when this would go live? |
|
I'll take a look and see if anything else needs to be patched but otherwise within the next day or two |
|
Oh I wanted to check, is there a better way to detect an unauthenticated error? Currently I have this not-so-pretty chunk of code: |
|
Woo, pyramid of doom! Takes me back to the early days of Swift 😃 So a couple suggestions: First, use guard
let responseError = error as? GraphQLHTTPResponseError,
let graphQLError = responseError.graphQLErrors?.first,
let extensions = graphQLError.extensions,
let code = extensions["code"] else {
// No error code to deal with
return
}
switch (code) {
case "UNAUTHENTICATED":
// Kick to login screen
default:
// Whatever else you need to do
} |
|
OK gonna merge this, it'll go out in the next patch release - I'll ping your other issue once it ships. |
This PR addresses #742 (which is a re-file of #477), and makes sure that when an
HTTPResponseErroris received, errors are properly parsed.I also added some tests on this as a net for the future.