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

[BUGFIX beta] Ensure wrapped errors are logged properly. #10475

Merged
merged 1 commit into from
Feb 16, 2015
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
8 changes: 7 additions & 1 deletion packages/ember-routing/lib/system/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -760,8 +760,14 @@ var defaultActionHandlers = {
}
};

function logError(error, initialMessage) {
function logError(_error, initialMessage) {
var errorArgs = [];
var error;
if (_error && typeof _error === 'object' && typeof _error.errorThrown === 'object') {
error = _error.errorThrown;
} else {
error = _error;
}

if (initialMessage) { errorArgs.push(initialMessage); }

Expand Down
25 changes: 25 additions & 0 deletions packages/ember/tests/routing/basic_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3196,6 +3196,31 @@ QUnit.test("rejecting the model hooks promise with a non-error prints the `messa
bootApplication();
});

QUnit.test("rejecting the model hooks promise with an error with `errorThrown` property prints `errorThrown.message` property", function() {
var rejectedMessage = 'OMG!! SOOOOOO BAD!!!!';
var rejectedStack = 'Yeah, buddy: stack gets printed too.';

Router.map(function() {
this.route("yippie", { path: "/" });
});

Ember.Logger.error = function(initialMessage, errorMessage, errorStack) {
equal(initialMessage, 'Error while processing route: yippie', 'a message with the current route name is printed');
equal(errorMessage, rejectedMessage, "the rejected reason's message property is logged");
equal(errorStack, rejectedStack, "the rejected reason's stack property is logged");
};

App.YippieRoute = Ember.Route.extend({
model: function() {
return Ember.RSVP.reject({
errorThrown: { message: rejectedMessage, stack: rejectedStack }
});
}
});

bootApplication();
});

QUnit.test("rejecting the model hooks promise with no reason still logs error", function() {
Router.map(function() {
this.route("wowzers", { path: "/" });
Expand Down