diff --git a/packages/ember-metal/lib/error_handler.js b/packages/ember-metal/lib/error_handler.js index d7173bdf362..79f35b058b6 100644 --- a/packages/ember-metal/lib/error_handler.js +++ b/packages/ember-metal/lib/error_handler.js @@ -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; } diff --git a/packages/ember-runtime/tests/ext/rsvp_test.js b/packages/ember-runtime/tests/ext/rsvp_test.js index 79713b93fc6..5887dcf0d90 100644 --- a/packages/ember-runtime/tests/ext/rsvp_test.js +++ b/packages/ember-runtime/tests/ext/rsvp_test.js @@ -35,6 +35,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);