{"action":"created","issue":{"url":"https://api.github.com/repos/agraboso/redux-api-middleware/issues/6","labels_url":"https://api.github.com/repos/agraboso/redux-api-middleware/issues/6/labels{/name}","comments_url":"https://api.github.com/repos/agraboso/redux-api-middleware/issues/6/comments","events_url":"https://api.github.com/repos/agraboso/redux-api-middleware/issues/6/events","html_url":"https://github.com/agraboso/redux-api-middleware/pull/6","id":105892958,"number":6,"title":"Proposal: Include response object in Error","user":{"login":"mohanzhang","id":241114,"avatar_url":"https://avatars.githubusercontent.com/u/241114?v=3","gravatar_id":"","url":"https://api.github.com/users/mohanzhang","html_url":"https://github.com/mohanzhang","followers_url":"https://api.github.com/users/mohanzhang/followers","following_url":"https://api.github.com/users/mohanzhang/following{/other_user}","gists_url":"https://api.github.com/users/mohanzhang/gists{/gist_id}","starred_url":"https://api.github.com/users/mohanzhang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mohanzhang/subscriptions","organizations_url":"https://api.github.com/users/mohanzhang/orgs","repos_url":"https://api.github.com/users/mohanzhang/repos","events_url":"https://api.github.com/users/mohanzhang/events{/privacy}","received_events_url":"https://api.github.com/users/mohanzhang/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-09-10T20:38:05Z","updated_at":"2015-09-10T23:09:00Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/agraboso/redux-api-middleware/pulls/6","html_url":"https://github.com/agraboso/redux-api-middleware/pull/6","diff_url":"https://github.com/agraboso/redux-api-middleware/pull/6.diff","patch_url":"https://github.com/agraboso/redux-api-middleware/pull/6.patch"},"body":"Currently, when a call fails, a new Error is created:\r\n\r\n```js\r\nreturn Promise.reject(new Error(`${response.status} - ${response.statusText}`));\r\n```\r\n\r\nHowever, especially for backends that return json responses, the response itself may be useful as it contains some error information, possibly along the lines of, e.g.:\r\n\r\n```js\r\n{ \"error\": \"my custom error message\" }\r\n```\r\n\r\nIt would be useful if there was some way to pass on the entire response so that the caller can then deal with it as necesary (and redux-api-middleware is agnostic to this). My idea was to create a new ApiError class that extends Error with an additional field `response`. The middleware can then fail calls with:\r\n\r\n```js\r\nreturn Promise.reject(new ApiError(response));\r\n```"},"comment":{"url":"https://api.github.com/repos/agraboso/redux-api-middleware/issues/comments/139407625","html_url":"https://github.com/agraboso/redux-api-middleware/pull/6#issuecomment-139407625","issue_url":"https://api.github.com/repos/agraboso/redux-api-middleware/issues/6","id":139407625,"user":{"login":"mohanzhang","id":241114,"avatar_url":"https://avatars.githubusercontent.com/u/241114?v=3","gravatar_id":"","url":"https://api.github.com/users/mohanzhang","html_url":"https://github.com/mohanzhang","followers_url":"https://api.github.com/users/mohanzhang/followers","following_url":"https://api.github.com/users/mohanzhang/following{/other_user}","gists_url":"https://api.github.com/users/mohanzhang/gists{/gist_id}","starred_url":"https://api.github.com/users/mohanzhang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mohanzhang/subscriptions","organizations_url":"https://api.github.com/users/mohanzhang/orgs","repos_url":"https://api.github.com/users/mohanzhang/repos","events_url":"https://api.github.com/users/mohanzhang/events{/privacy}","received_events_url":"https://api.github.com/users/mohanzhang/received_events","type":"User","site_admin":false},"created_at":"2015-09-10T23:08:59Z","updated_at":"2015-09-10T23:08:59Z","body":"@agraboso No rush at all. I am running off my own fork for now so please enjoy your digital disconnection and its after-effects ;)"}}