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

fix: use original Error object for uncaught errors when provided in browser #5080

Closed
wants to merge 1 commit into from
Closed
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
7 changes: 5 additions & 2 deletions browser-entry.js
Copy link
Member

Choose a reason for hiding this comment

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

[Testing] Could you add a unit test too, please?

#5107 has a reference if that's helpful.

Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,11 @@ process.listenerCount = function (name) {

process.on = function (e, fn) {
if (e === 'uncaughtException') {
global.onerror = function (err, url, line) {
fn(new Error(err + ' (' + url + ':' + line + ')'));
global.onerror = function (err, url, line, colno, error) {
if (!error) {
error = new Error(err + ' (' + url + ':' + line + ')');
}
fn(error);
Copy link
Member

Choose a reason for hiding this comment

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

Aha! I'd filed #5106 before seeing this PR. Great. I'll close that one since this once came first.

[Feature] What do you think about including ':' + col too, per https://github.com/mochajs/mocha/pull/5107/files#diff-c282db01f80ee266af40ae81278d9d99177c763ae242fdeb38ee33c603598a2fR75 ?

Request adding it in as a new nicety, unless you know of a reason not to.

return !mocha.options.allowUncaught;
};
uncaughtExceptionHandlers.push(fn);
Expand Down
Loading