Skip to content

Commit

Permalink
Use original Error object for uncaught errors when provided
Browse files Browse the repository at this point in the history
In case of uncaught errors, mocha would print the error message, which is essentially the first line of the stack trace. The actual stack trace was unused.
  • Loading branch information
karyon authored Jan 18, 2024
1 parent 53a4baf commit 0d4042f
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions browser-entry.js
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);
return !mocha.options.allowUncaught;
};
uncaughtExceptionHandlers.push(fn);
Expand Down

0 comments on commit 0d4042f

Please sign in to comment.