Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
When Non-OK Response Received from fetch, throw an error including the response #1205
This provides the Response provided from
I noticed that these issues are around a similar situation, but have somewhat different designs. If this change is too large for this PR, I'll be glad to break it up (one for each issue).
…K response is received from the server. It includes a new error called HttpNetworkError which includes the response which failed. A new fake IResponse interface function was created to help aid in testing.
@calebmer - Thanks for the review! I appreciate the time and effort.
You mentioned wanting a better story around why this change would be needed. I'll try and elaborate here a bit. If this isn't what you were looking for, my apologies.
When you deal with a network that may have issues (a backing service goes down or the user is required to be authenticated) it's hard to determine what the network-related issue was. So when doing this today:
You will get a networkError, but the error message will look something like this because of Issue 1199
That's because the response is assumed to be OK at this point and will attempted to be parsed. Depending on the body of the message, the error may look different.
This can be fixed by making the adjustments outlined in Issue 1199. Without having the response provided though,
If adding another error is something we want to avoid, I'll take a look into avoiding that.
Yep, I totally agree that we need to throw a better error and fix #1199. I’m just not convinced another error class is the solution so let’s definitely look into ways to attach the response without a new class. I think I have an idea, I’ll leave another comment in the code