[fetch] Regarding "switch on response's status" (#60)

Regarding https://fetch.spec.whatwg.org/#http-fetch -> "switch on response's status":

Dear WHATWG

Shouldn't a 404 be handled as error?

While using a fetch() polyfill I was surprised that my .catch block wasn't called.

Now I added this:

```
if (response.status === 200) {
  return response;
} else {
  throw new Error(response.statusText);
}
```

But I had expected fetch() to throw an error when it receives (eg) a 404.
I wanted to "fetch" a file and the server replied "not found" - this is a failure, and it might surprise other user of your API as well that it doesn't get reported as error.

Perhaps specify it as default behavior?
And perhaps offer some flag which gives the API user the option of handling the status code himself, completely.

Tobi

---
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/fetch/issues/60

Received on Wednesday, 3 June 2015 11:09:07 UTC