{"action":"created","issue":{"url":"https://api.github.com/repos/angular/angular.js/issues/13990","repository_url":"https://api.github.com/repos/angular/angular.js","labels_url":"https://api.github.com/repos/angular/angular.js/issues/13990/labels{/name}","comments_url":"https://api.github.com/repos/angular/angular.js/issues/13990/comments","events_url":"https://api.github.com/repos/angular/angular.js/issues/13990/events","html_url":"https://github.com/angular/angular.js/issues/13990","id":132608337,"number":13990,"title":"Is re-throwing in promises going to be supported by $q at some point?","user":{"login":"adambuczynski","id":490562,"avatar_url":"https://avatars.githubusercontent.com/u/490562?v=3","gravatar_id":"","url":"https://api.github.com/users/adambuczynski","html_url":"https://github.com/adambuczynski","followers_url":"https://api.github.com/users/adambuczynski/followers","following_url":"https://api.github.com/users/adambuczynski/following{/other_user}","gists_url":"https://api.github.com/users/adambuczynski/gists{/gist_id}","starred_url":"https://api.github.com/users/adambuczynski/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adambuczynski/subscriptions","organizations_url":"https://api.github.com/users/adambuczynski/orgs","repos_url":"https://api.github.com/users/adambuczynski/repos","events_url":"https://api.github.com/users/adambuczynski/events{/privacy}","received_events_url":"https://api.github.com/users/adambuczynski/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-02-10T05:10:14Z","updated_at":"2016-02-10T09:51:01Z","closed_at":"2016-02-10T09:51:00Z","body":"The docs for `$q` state:\r\n\r\n> Note: unlike ES6 behavior, an exception thrown in the constructor function will NOT implicitly reject the promise.\r\n\r\nand\r\n\r\n> This also means that if you \"catch\" an error via a promise error callback and you want to forward the error to the promise derived from the current promise, you have to \"rethrow\" the error by returning a rejection constructed via reject\r\n\r\nSo my question is, is this planned to be supported at any time in Angular 1? In a successful `.then` chain we can keep returning the same item/data, or modify it and return that, so why not re-throw an error in `.catch` that occurred without needing to include `$q` as a dependency?\r\n\r\nE.g.\r\n\r\n```js\r\ndoSomething\r\n  .catch(error => {\r\n    doSomethingElse();\r\n    throw error;\r\n  });\r\n```\r\n\r\ninstead of:\r\n\r\n```js\r\ndoSomething\r\n  .catch(error => {\r\n    doSomethingElse();\r\n    return $q.reject(error);\r\n  });\r\n```\r\n\r\nIf not, is there a specific reason for this not being supported in `$q`?\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/angular/angular.js/issues/comments/182282884","html_url":"https://github.com/angular/angular.js/issues/13990#issuecomment-182282884","issue_url":"https://api.github.com/repos/angular/angular.js/issues/13990","id":182282884,"user":{"login":"gkalpak","id":8604205,"avatar_url":"https://avatars.githubusercontent.com/u/8604205?v=3","gravatar_id":"","url":"https://api.github.com/users/gkalpak","html_url":"https://github.com/gkalpak","followers_url":"https://api.github.com/users/gkalpak/followers","following_url":"https://api.github.com/users/gkalpak/following{/other_user}","gists_url":"https://api.github.com/users/gkalpak/gists{/gist_id}","starred_url":"https://api.github.com/users/gkalpak/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gkalpak/subscriptions","organizations_url":"https://api.github.com/users/gkalpak/orgs","repos_url":"https://api.github.com/users/gkalpak/repos","events_url":"https://api.github.com/users/gkalpak/events{/privacy}","received_events_url":"https://api.github.com/users/gkalpak/received_events","type":"User","site_admin":false},"created_at":"2016-02-10T09:51:00Z","updated_at":"2016-02-10T09:51:00Z","body":"Throwing an error from within a `.then` or `.catch` callback does already work for rejecting the promise.\r\n\r\n--\r\nIt seems like you have misinterpreted the quoted statements:\r\n\r\n> Note: unlike ES6 behavior, an exception thrown in the constructor function will NOT implicitly reject the promise.\r\n\r\nThis only refers to the throwing from within the **contructor** (i.e. `resolver` function), when using `$q` as a constructor (ES6-style). E.g.:\r\n\r\n```js\r\n$q(function (resolve, reject) {\r\n  throw new Error('From constructor !');\r\n}).then(\r\n  // Will never get here unless you call `resolve()` or `reject()`.\r\n  // Throwing won't work !\r\n);\r\n```\r\n\r\nBut it's OK, because when using `$q` like this, you can use the `reject` function argument, so no need for `$q.reject()`.\r\n\r\n--\r\n> This also means that if you \"catch\" an error via a promise error callback and you want to forward the error to the promise derived from the current promise, you have to \"rethrow\" the error by returning a rejection constructed via reject\r\n\r\nThe key word here is \"forward\". Throwing an error will still work for **rejecting** the promise, but it does not do a good job at **forwarding** the initial error, because the next rejection handler will get your thrown error as argument.\r\nSo, if you only care to propagate the rejection, throwing is enough. If you want to propagate the error (which could be anything from null, to an error message string, to a custom object), you need to use `$q.reject()`.\r\n\r\n---\r\nClosing as it seems like what you are asking is already supported.\r\nFeel free to reopen, if I missed something :smiley:"}}