Skip to content

Commit

Permalink
[BUGFIX beta] run(rsvp, "reject") should not throw trying to dispatch…
Browse files Browse the repository at this point in the history
…Error

(cherry picked from commit 4f39ebc)
  • Loading branch information
Jason Mitchell authored and Robert Jackson committed Sep 13, 2016
1 parent 664a3ec commit 143342f
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/ember-metal/lib/error_handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ let getStack = function(error) {
var stack = error.stack;
var message = error.message;

if (stack.indexOf(message) === -1) {
if (stack && stack.indexOf(message) === -1) {
stack = message + '\n' + stack;
}

Expand Down
32 changes: 32 additions & 0 deletions packages/ember-runtime/tests/ext/rsvp_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,38 @@ QUnit.test('TransitionAborted errors are not re-thrown', function() {
ok(true, 'did not throw an error when dealing with TransitionAborted');
});

QUnit.test('Can reject with non-Error object', function(assert) {
let wasEmberTesting = isTesting();
setTesting(false);
expect(1);

try {
run(RSVP, 'reject', 'foo');
} catch(e) {
ok(false, 'should not throw');
} finally {
setTesting(wasEmberTesting);
}

ok(true);
});

QUnit.test('Can reject with no arguments', function(assert) {
let wasEmberTesting = isTesting();
setTesting(false);
expect(1);

try {
run(RSVP, 'reject');
} catch(e) {
ok(false, 'should not throw');
} finally {
setTesting(wasEmberTesting);
}

ok(true);
});

QUnit.test('rejections like jqXHR which have errorThrown property work', function() {
expect(2);

Expand Down

0 comments on commit 143342f

Please sign in to comment.