# Errors handling

**URL:** https://discuss.emberjs.com/t/errors-handling/16368
**Category:** General
**Created:** [March 27, 2019, 9:53am UTC](https://discuss.emberjs.com/t/errors-handling/16368 "2019-03-27T09:53:03Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![belgoros](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/belgoros/32/16101_2.png) [@belgoros](https://discuss.emberjs.com/u/belgoros)
#### Post date: [March 27, 2019, 9:53am UTC](https://discuss.emberjs.com/t/errors-handling/16368/1 "2019-03-27T09:53:03Z")

</div>

I found this [section](https://guides.emberjs.com/release/configuring-ember/debugging/#toc_errors-within-an-rsvppromise) in Ember Guides explaining the debugging configuration.

The questions I have are:

1. What is the right place to put the suggested code-snippet inside of `app.js`:

```auto
RSVP.on('error', function(error) {
  assert(error, false);
});

```

if the `app.js` already have has the following lines:

```auto
# app.js

import Application from '@ember/application';
import Resolver from './resolver';
import loadInitializers from 'ember-load-initializers';
import config from './config/environment';

const App = Application.extend({
  modulePrefix: config.modulePrefix,
  podModulePrefix: config.podModulePrefix,
  Resolver
});

loadInitializers(App, config.modulePrefix);

export default App;

```

1. How is it related and is it still valid to use an initializer and put the following errors handlers in it:

```auto
# initializers/catch-all-errors.js

// Global error handler in Ember run loop
Ember.onerror = function (err) {
    console.log(err);
};

// Global error handler for promises
Ember.RSVP.on('error', function(err) {
    console.log(err);
});

```

based on [this blog article](https://slides.com/gzurbach/error-handling-and-monitoring-with-ember#/13) ?

Thank you!

---

<div class="post-metadata">

### Author: ![ef4](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/ef4/32/13470_2.png) [@ef4](https://discuss.emberjs.com/u/ef4)
#### Post date: [March 27, 2019, 3:40pm UTC](https://discuss.emberjs.com/t/errors-handling/16368/2 "2019-03-27T15:40:07Z")

</div>

Inside of `app.js` you can put it anywhere. The whole module is going to be evaluated before the app boots so it’s not very important.

Your initializer example is doing the same thing. You don’t need both.

`Ember.RSVP.on(...)` is an older way of saying `import RSVP from 'rsvp'; RSVP.on(...);`. They are the same RSVP object.

---

<div class="post-metadata">

### Author: ![belgoros](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/belgoros/32/16101_2.png) [@belgoros](https://discuss.emberjs.com/u/belgoros)
#### Post date: [March 27, 2019, 3:53pm UTC](https://discuss.emberjs.com/t/errors-handling/16368/3 "2019-03-27T15:53:07Z")

</div>

Thank you for your response, @ef4. But when I use `console.log(err);`, Ember linter sees that as an error pointing out to the use of `console` statement, is it OK though?

---

<div class="post-metadata">

### Author: ![ef4](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/ef4/32/13470_2.png) [@ef4](https://discuss.emberjs.com/u/ef4)
#### Post date: [March 27, 2019, 6:18pm UTC](https://discuss.emberjs.com/t/errors-handling/16368/4 "2019-03-27T18:18:52Z")

</div>

The linter rules are just suggestions, if you decide you are OK with having console statements in your code then you can turn off that rule, or use a comment to suppress the error in this one place.

I think people mostly view `console.log` as a temporary thing useful while debugging an issue but then removed before you commit and go to production.

---

<div class="post-metadata">

### Author: ![belgoros](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/belgoros/32/16101_2.png) [@belgoros](https://discuss.emberjs.com/u/belgoros)
#### Post date: [March 28, 2019, 9:02am UTC](https://discuss.emberjs.com/t/errors-handling/16368/5 "2019-03-28T09:02:35Z")

</div>

@ef4 Ok, thank you very much. I got it.
