fix: properly nullify error stacks (#836)
`error.stack` is supposed to have error message as the first line.
This commit is contained in:
parent
e3e2da3186
commit
0c2a2e11fd
|
|
@ -101,6 +101,7 @@ export function toConsoleMessageLocation(stackTrace: Protocol.Runtime.StackTrace
|
||||||
export function exceptionToError(exceptionDetails: Protocol.Runtime.ExceptionDetails): Error {
|
export function exceptionToError(exceptionDetails: Protocol.Runtime.ExceptionDetails): Error {
|
||||||
const message = getExceptionMessage(exceptionDetails);
|
const message = getExceptionMessage(exceptionDetails);
|
||||||
const err = new Error(message);
|
const err = new Error(message);
|
||||||
err.stack = ''; // Don't report clientside error with a node stack attached
|
// Don't report clientside error with a node stack attached
|
||||||
|
err.stack = 'Error: ' + err.message; // Stack is supposed to contain error message as the first line.
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -152,7 +152,8 @@ export class Page extends platform.EventEmitter {
|
||||||
|
|
||||||
_didCrash() {
|
_didCrash() {
|
||||||
const error = new Error('Page crashed!');
|
const error = new Error('Page crashed!');
|
||||||
error.stack = '';
|
// Do not report node.js stack.
|
||||||
|
error.stack = 'Error: ' + error.message; // Stack is supposed to contain error message as the first line.
|
||||||
this.emit('error', error);
|
this.emit('error', error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -322,7 +322,7 @@ export class WKPage implements PageDelegate {
|
||||||
}
|
}
|
||||||
if (level === 'error' && source === 'javascript') {
|
if (level === 'error' && source === 'javascript') {
|
||||||
const error = new Error(text);
|
const error = new Error(text);
|
||||||
error.stack = '';
|
error.stack = 'Error: ' + error.message; // Nullify stack. Stack is supposed to contain error message as the first line.
|
||||||
this._page.emit(Events.Page.PageError, error);
|
this._page.emit(Events.Page.PageError, error);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue