Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

run(rsvp, "reject") should not throw trying to dispatchError #14184

Merged
merged 1 commit into from
Sep 2, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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) {
Copy link
Member Author

@jasonmit jasonmit Sep 1, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

synonymous with the previous behavior where it will Log/dispatch undefined if the error did not have a stack

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 @@ -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);

Expand Down