mirror of
https://github.com/microsoft/playwright.git
synced 2024-12-15 06:02:57 +03:00
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 {
|
||||
const message = getExceptionMessage(exceptionDetails);
|
||||
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;
|
||||
}
|
||||
|
@ -152,7 +152,8 @@ export class Page extends platform.EventEmitter {
|
||||
|
||||
_didCrash() {
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -322,7 +322,7 @@ export class WKPage implements PageDelegate {
|
||||
}
|
||||
if (level === 'error' && source === 'javascript') {
|
||||
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);
|
||||
return;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user