Don’t let Ember.js swallow errors in your promises

Update: 25/07/2013 : The solution described below does not work with RC6 .. You will need to get ember-latest.

Are you finding that errors occurring in your promise handlers are being swallowed silently by Ember.js ? I had written some code that looked like this:

The problem was that I was calling this.getXXX while in the scope of the then() function, which is globally scoped. This was easily fixed by passing a reference to controller scope, but normally these kind of mistakes are logged to the console.

Turns out the then() callback function was being executed by Ember.js in a try/catch block, with the error being passed to the default reject handler which was swallowing the error.

Luckily @teddyzeenny was in the IRC channel to offer some advice. Heres a code snippet that you can add to your Ember.js application to make sure these errors get logged to the console.

Advertisements
This entry was posted in Uncategorized and tagged , , , , , , , . Bookmark the permalink.

8 Responses to Don’t let Ember.js swallow errors in your promises

  1. Pingback: Don't let Ember.js swallow errors in your promi...

  2. Marcus Böhm says:

    This seems to be not available in Ember RC6. Do you know of any workaround in RC6? Thanks!

  3. FYI: Ember now ships with a very similar default.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s