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

Use single console.error() statement in error handler #1471

Merged
merged 1 commit into from Jun 13, 2020
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 1 addition & 3 deletions lib/application.js
Expand Up @@ -201,9 +201,7 @@ module.exports = class Application extends Emitter {
if (this.silent) return;

const msg = err.stack || err.toString();
console.error();
console.error(msg.replace(/^/gm, ' '));
console.error();
console.error(`\n${msg.replace(/^/gm, ' ')}\n`);
}
};

Expand Down
4 changes: 2 additions & 2 deletions test/application/onerror.js
Expand Up @@ -51,7 +51,7 @@ describe('app.onerror(err)', () => {
if (input) msg = input;
});
app.onerror(err);
assert(msg === ' Foo');
assert(msg === '\n Foo\n');
});

it('should use err.toString() instad of err.stack', () => {
Expand All @@ -68,6 +68,6 @@ describe('app.onerror(err)', () => {
if (input) msg = input;
});
app.onerror(err);
assert(msg === ' Error: mock stack null');
assert(msg === '\n Error: mock stack null\n');
});
});