# Local handling of promise rejections

**URL:** <https://discuss.emberjs.com/t/local-handling-of-promise-rejections/7776>\
**Category:** Design\
**Created:** [April 11, 2015, 7:02am UTC](https://discuss.emberjs.com/t/local-handling-of-promise-rejections/7776 "2015-04-11T07:02:52Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![guigouz](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/guigouz/32/9122_2.png) [@guigouz](https://discuss.emberjs.com/u/guigouz)\
**Post date:** [April 11, 2015, 7:02am UTC](https://discuss.emberjs.com/t/local-handling-of-promise-rejections/7776/1 "2015-04-11T07:02:52Z")

</div>

I’m currently implementing error monitoring in my app using the well-know global error handlers:

```javascript
Ember.onerror = function (err) {
    trackJs.track(err);
    Ember.Logger.assert(false, err);
};

Ember.RSVP.on('error', function (err) {
    trackJs.track(err);
    Ember.Logger.assert(false, err);
});

```

That said, when I’m creating or updating a record I’d like to show custom error messages to the user or even swallow errors in specific conditions. For instance:

```auto
post.save().then(function () {
  // things went well
}).catch(function (err) {
  notify.error('Your post could not be saved.');
  if (err.response.status === 403) {
    notify.error('You are not allowed to post here.');
  }
  if (err.response.status === 500) {
    // holly shit something went wrong, gotta let that stuff bubble up to the global error handler
    Ember.RSVP.reject(err);
  }
});

```

It feels like a common need to be able to `catch` rejections locally, do something with them, and potentially let them bubble up to be managed in a centralized location. Does using `Ember.RSVP.reject()` makes sense here or should I do something else?

Thanks!

---

<div class="post-metadata">

**Author:** ![stefan](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/stefan/32/14174_2.png) [@stefan](https://discuss.emberjs.com/u/stefan)\
**Post date:** [April 11, 2015, 6:16pm UTC](https://discuss.emberjs.com/t/local-handling-of-promise-rejections/7776/2 "2015-04-11T18:16:44Z")

</div>

> [@guigouz](#):
>
> Does using Ember.RSVP.reject() makes sense here or should I do something else?

just `throw`

```js
post.save().then(function () {
  // things went well
}).catch(function (err) {
  notify.error('Your post could not be saved.');
  if (err.response.status === 403) {
    notify.error('You are not allowed to post here.');
  }
    throw err;
});

```

---

<div class="post-metadata">

**Author:** ![guigouz](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/guigouz/32/9122_2.png) [@guigouz](https://discuss.emberjs.com/u/guigouz)\
**Post date:** [April 12, 2015, 3:24am UTC](https://discuss.emberjs.com/t/local-handling-of-promise-rejections/7776/3 "2015-04-12T03:24:47Z")

</div>

Sometimes the answer is way simpler than I would imagine. Thanks for taking the time to answer my question!
