# Where to declate Ember.onerror

**URL:** https://discuss.emberjs.com/t/where-to-declate-ember-onerror/7185
**Category:** Ember CLI
**Created:** [January 29, 2015, 9:52am UTC](https://discuss.emberjs.com/t/where-to-declate-ember-onerror/7185 "2015-01-29T09:52:02Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![kgish](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/kgish/32/13333_2.png) [@kgish](https://discuss.emberjs.com/u/kgish)
#### Post date: [January 29, 2015, 9:52am UTC](https://discuss.emberjs.com/t/where-to-declate-ember-onerror/7185/1 "2015-01-29T09:52:02Z")

</div>

Where’s the correct place to declare `Ember.onerror = function(error){...}` in ember-cli?

---

<div class="post-metadata">

### Author: ![Panman8201](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/panman8201/32/17727_2.png) [@Panman8201](https://discuss.emberjs.com/u/Panman8201)
#### Post date: [January 30, 2015, 12:00am UTC](https://discuss.emberjs.com/t/where-to-declate-ember-onerror/7185/2 "2015-01-30T00:00:10Z")

</div>

Have you tried setting that in your `app/app.js` file? I seem to recall hearing about that before but don’t quite remember what the answer is.

---

<div class="post-metadata">

### Author: ![jcope2013](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/jcope2013/32/9878_2.png) [@jcope2013](https://discuss.emberjs.com/u/jcope2013)
#### Post date: [January 30, 2015, 12:10am UTC](https://discuss.emberjs.com/t/where-to-declate-ember-onerror/7185/3 "2015-01-30T00:10:38Z")

</div>

i created an error handling initializer and put it in there

---

<div class="post-metadata">

### Author: ![MiguelMadero](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/miguelmadero/32/15187_2.png) [@MiguelMadero](https://discuss.emberjs.com/u/MiguelMadero)
#### Post date: [January 30, 2015, 7:29am UTC](https://discuss.emberjs.com/t/where-to-declate-ember-onerror/7185/4 "2015-01-30T07:29:35Z")

</div>

+1 for initializer, that’s also how I did it.

---

<div class="post-metadata">

### Author: ![kgish](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/kgish/32/13333_2.png) [@kgish](https://discuss.emberjs.com/u/kgish)
#### Post date: [January 30, 2015, 11:29am UTC](https://discuss.emberjs.com/t/where-to-declate-ember-onerror/7185/5 "2015-01-30T11:29:23Z")

</div>

Initializer makes the best sense to me, thanks.

---

<div class="post-metadata">

### Author: ![jdurand](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/jdurand/32/12258_2.png) [@jdurand](https://discuss.emberjs.com/u/jdurand)
#### Post date: [April 21, 2016, 12:18am UTC](https://discuss.emberjs.com/t/where-to-declate-ember-onerror/7185/6 "2016-04-21T00:18:41Z")

</div>

I also added this to an initializer, but defining a method on the Ember global object feels wrong. Is there another way to achieve this?
