Skip to content

Commit

Permalink
chore: Use single console.error() statement in error handler (#1471)
Browse files Browse the repository at this point in the history
  • Loading branch information
mpvosseller authored Jun 13, 2020
1 parent 9ee6584 commit 5208c5e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
4 changes: 1 addition & 3 deletions lib/application.js
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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');
});
});

0 comments on commit 5208c5e

Please sign in to comment.