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

Error message to be shown when formatting Error #446

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
Error message to be shown when formatting Error
In case an Error to be formatted has a message, add it on top of the error stack. Sometimes error message is more useful than error stack, which is oftentimes doesn't have anything except when.js methods chain.
Feasul committed Apr 9, 2015

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 12a59ada4d72ef694d2b1b9129f259f3e34c14e6
3 changes: 2 additions & 1 deletion lib/format.js
Original file line number Diff line number Diff line change
@@ -20,7 +20,8 @@ define(function() {
*/
function formatError(e) {
var s = typeof e === 'object' && e !== null && e.stack ? e.stack : formatObject(e);
return e instanceof Error ? s : s + ' (WARNING: non-Error used)';
var m = typeof e === 'object' && e !== null && e.message ? e.message + '\n' : '';
return e instanceof Error ? m + s : s + ' (WARNING: non-Error used)';
}

/**