{"action":"created","issue":{"url":"https://api.github.com/repos/tildeio/rsvp.js/issues/363","labels_url":"https://api.github.com/repos/tildeio/rsvp.js/issues/363/labels{/name}","comments_url":"https://api.github.com/repos/tildeio/rsvp.js/issues/363/comments","events_url":"https://api.github.com/repos/tildeio/rsvp.js/issues/363/events","html_url":"https://github.com/tildeio/rsvp.js/issues/363","id":56799379,"number":363,"title":"Feature request: shortcut to create prefulfilled and prerejected promises","user":{"login":"lolmaus","id":200884,"avatar_url":"https://avatars.githubusercontent.com/u/200884?v=3","gravatar_id":"","url":"https://api.github.com/users/lolmaus","html_url":"https://github.com/lolmaus","followers_url":"https://api.github.com/users/lolmaus/followers","following_url":"https://api.github.com/users/lolmaus/following{/other_user}","gists_url":"https://api.github.com/users/lolmaus/gists{/gist_id}","starred_url":"https://api.github.com/users/lolmaus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lolmaus/subscriptions","organizations_url":"https://api.github.com/users/lolmaus/orgs","repos_url":"https://api.github.com/users/lolmaus/repos","events_url":"https://api.github.com/users/lolmaus/events{/privacy}","received_events_url":"https://api.github.com/users/lolmaus/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-02-06T11:11:03Z","updated_at":"2015-02-06T14:28:36Z","closed_at":"2015-02-06T14:18:31Z","body":"I've discovered that `.then( function() {}, function() {} )` returns a positively resolved promise even if the initial promise was rejected, while `.then( function() {} )` would return a rejected promise. This is counter-intuitive to me, but i guess this is how ES6 is designed, so it's useless to whine about it.\r\n\r\nAnyway, to work this around, i have to explicitly return a rejected promise from the failure callback of `.then()`:\r\n\r\n```js\r\nreturn somePromise .then(\r\n  function(data) {\r\n    // Success\r\n    return data;\r\n  },\r\n  function(data) {\r\n    // Failure\r\n    var rejectedPromise = new RSVP.Promise(\r\n      function (resolve, reject) {\r\n        reject(data);\r\n      }\r\n    );\r\n    return rejectedPromise;\r\n  };\r\n);\r\n```\r\n\r\nThis is a terrible amount of code to write. I can think of this instead:\r\n\r\n\r\n```js\r\nreturn somePromise .then(\r\n  function(data) {\r\n    // Success\r\n    return data;\r\n  },\r\n  function(data) {\r\n    // Failure\r\n    return RSVP.rejectedPromise(data);\r\n  };\r\n);\r\n```"},"comment":{"url":"https://api.github.com/repos/tildeio/rsvp.js/issues/comments/73244010","html_url":"https://github.com/tildeio/rsvp.js/issues/363#issuecomment-73244010","issue_url":"https://api.github.com/repos/tildeio/rsvp.js/issues/363","id":73244010,"user":{"login":"lolmaus","id":200884,"avatar_url":"https://avatars.githubusercontent.com/u/200884?v=3","gravatar_id":"","url":"https://api.github.com/users/lolmaus","html_url":"https://github.com/lolmaus","followers_url":"https://api.github.com/users/lolmaus/followers","following_url":"https://api.github.com/users/lolmaus/following{/other_user}","gists_url":"https://api.github.com/users/lolmaus/gists{/gist_id}","starred_url":"https://api.github.com/users/lolmaus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lolmaus/subscriptions","organizations_url":"https://api.github.com/users/lolmaus/orgs","repos_url":"https://api.github.com/users/lolmaus/repos","events_url":"https://api.github.com/users/lolmaus/events{/privacy}","received_events_url":"https://api.github.com/users/lolmaus/received_events","type":"User","site_admin":false},"created_at":"2015-02-06T14:28:36Z","updated_at":"2015-02-06T14:28:36Z","body":"> `throw reason;`\r\n\r\nOh, i didn't know that promises catch all errors thrown from inside `then` callbacks. I thought they would leak. Learning every day! :D\r\n\r\n\r\n> Additionally, the following short-hands exist.\r\n\r\nThank you, @stefanpenner! This is exactly what i wanted.\r\n\r\nMy teammate @gleb-osokin told me that those exist already, but we failed to find them mentioned in RSVP readme. Why are they not mentioned?\r\n\r\n"}}