{"action":"created","issue":{"url":"https://api.github.com/repos/github/fetch/issues/155","labels_url":"https://api.github.com/repos/github/fetch/issues/155/labels{/name}","comments_url":"https://api.github.com/repos/github/fetch/issues/155/comments","events_url":"https://api.github.com/repos/github/fetch/issues/155/events","html_url":"https://github.com/github/fetch/issues/155","id":84477017,"number":155,"title":"fetch should throw an error when it receives a 404","user":{"login":"tobireif","id":80411,"avatar_url":"https://avatars.githubusercontent.com/u/80411?v=3","gravatar_id":"","url":"https://api.github.com/users/tobireif","html_url":"https://github.com/tobireif","followers_url":"https://api.github.com/users/tobireif/followers","following_url":"https://api.github.com/users/tobireif/following{/other_user}","gists_url":"https://api.github.com/users/tobireif/gists{/gist_id}","starred_url":"https://api.github.com/users/tobireif/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tobireif/subscriptions","organizations_url":"https://api.github.com/users/tobireif/orgs","repos_url":"https://api.github.com/users/tobireif/repos","events_url":"https://api.github.com/users/tobireif/events{/privacy}","received_events_url":"https://api.github.com/users/tobireif/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-06-03T10:11:18Z","updated_at":"2015-06-03T12:15:22Z","closed_at":"2015-06-03T10:20:23Z","body":"When there's eg a 404, fetch should throw an error, so that I can .catch() and handle it. (The error related code in the readme should be in fetch by default.)"},"comment":{"url":"https://api.github.com/repos/github/fetch/issues/comments/108353192","html_url":"https://github.com/github/fetch/issues/155#issuecomment-108353192","issue_url":"https://api.github.com/repos/github/fetch/issues/155","id":108353192,"user":{"login":"tobireif","id":80411,"avatar_url":"https://avatars.githubusercontent.com/u/80411?v=3","gravatar_id":"","url":"https://api.github.com/users/tobireif","html_url":"https://github.com/tobireif","followers_url":"https://api.github.com/users/tobireif/followers","following_url":"https://api.github.com/users/tobireif/following{/other_user}","gists_url":"https://api.github.com/users/tobireif/gists{/gist_id}","starred_url":"https://api.github.com/users/tobireif/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tobireif/subscriptions","organizations_url":"https://api.github.com/users/tobireif/orgs","repos_url":"https://api.github.com/users/tobireif/repos","events_url":"https://api.github.com/users/tobireif/events{/privacy}","received_events_url":"https://api.github.com/users/tobireif/received_events","type":"User","site_admin":false},"created_at":"2015-06-03T12:15:22Z","updated_at":"2015-06-03T12:15:22Z","body":"Actually, in this specific case, I want to accept only status 200, so having my own code \"if (response.status === 200) ...\" instead of \"if (response.status >= 200 && response.status < 300) ...\" is handy.\r\n\r\nThanks for the wrapper code, but for my project, the following is sufficient AFAICS:\r\n(Inside a Promise wrapper containing additional stuff:)\r\n```\r\nfetch(url)\r\n  .then(\r\n    fetchStatusHandler\r\n  ).then(function(response) {\r\n    return response.blob();\r\n  }).then(function(blob) {\r\n    resolve(blob.size);\r\n  }).catch(function(error) {\r\n    reject(error);\r\n  });\r\n```\r\n\r\nAlso: related: https://github.com/whatwg/fetch/issues/60 ."}}