# How to handle ember errors?

**URL:** https://discuss.emberjs.com/t/how-to-handle-ember-errors/18320
**Category:** Questions
**Created:** [October 30, 2020, 4:26pm UTC](https://discuss.emberjs.com/t/how-to-handle-ember-errors/18320 "2020-10-30T16:26:10Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![dimas09](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/dimas09/32/13393_2.png) [@dimas09](https://discuss.emberjs.com/u/dimas09)
#### Post date: [October 30, 2020, 4:26pm UTC](https://discuss.emberjs.com/t/how-to-handle-ember-errors/18320/1 "2020-10-30T16:26:10Z")

</div>

I’ve added the next code

```auto
Ember.onerror = function (error) {
    sendError(error);
        }

```

Yes, I get errors here but not all. For example, I can’t handle the next error: `Error in application route Error: Assertion Failed: You made a 'findAll' request for 'mymodel' records, but the adapter's response did not have any data`

I tried to add into `application` route:

```auto
    actions: {
        error(error, transition) {
            sendError(error);
        }
    }

```

But It doesn’t help.

---

<div class="post-metadata">

### Author: ![dknutsen](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/dknutsen/32/16471_2.png) [@dknutsen](https://discuss.emberjs.com/u/dknutsen)
#### Post date: [October 30, 2020, 7:26pm UTC](https://discuss.emberjs.com/t/how-to-handle-ember-errors/18320/2 "2020-10-30T19:26:52Z")

</div>

> [@dimas09](#):
>
> ```auto
> Ember.onerror = function (error) {
> sendError(error);
> }
> 
> ```

Where is this code in your app? You should probably have it in an initializer e.g.:

```auto
// app/initializers/error-handling.js
import Ember from 'ember';

function initialize(/* application */) {
  const onErrorSuper = Ember.onerror || function(e) {
    throw e;
  };

  // your custom handler here, this is just an example
  Ember.onerror = function(e) {
    if (e instanceof AppExplosion) {
      // Silence app explosions, they are not important.
    } else {
      onErrorSuper(e);
    }
  };
}

export default {
  name: 'error-handling',
  initialize
};

```

---

<div class="post-metadata">

### Author: ![dimas09](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/dimas09/32/13393_2.png) [@dimas09](https://discuss.emberjs.com/u/dimas09)
#### Post date: [November 1, 2020, 5:16pm UTC](https://discuss.emberjs.com/t/how-to-handle-ember-errors/18320/3 "2020-11-01T17:16:26Z")

</div>

Yes, I tried to add `onerror` handler in `instance-initializers`

---

<div class="post-metadata">

### Author: ![dimas09](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/dimas09/32/13393_2.png) [@dimas09](https://discuss.emberjs.com/u/dimas09)
#### Post date: [November 2, 2020, 10:18am UTC](https://discuss.emberjs.com/t/how-to-handle-ember-errors/18320/4 "2020-11-02T10:18:41Z")

</div>

Seems, `onerror` doesn’t catch errors like `Error in application route Error:.......`

---

<div class="post-metadata">

### Author: ![dknutsen](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/dknutsen/32/16471_2.png) [@dknutsen](https://discuss.emberjs.com/u/dknutsen)
#### Post date: [November 2, 2020, 3:19pm UTC](https://discuss.emberjs.com/t/how-to-handle-ember-errors/18320/5 "2020-11-02T15:19:42Z")

</div>

Hmmmm I feel like it still should. Have you tried a regular initializer instead of an instance initializer? That’s the only way I’ve done this before.
