fix: ensure stack trace contains one line (#10317)

This commit is contained in:
jrandolf 2023-06-06 09:11:46 +02:00 committed by GitHub
parent 109f981beb
commit bc0b04beef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -147,8 +147,11 @@ export function createClientError(
const getErrorDetails = (details: Protocol.Runtime.ExceptionDetails) => {
let name = '';
let message: string;
const lines = details.exception?.description?.split('\n') ?? [];
const size = details.stackTrace?.callFrames.length ?? 0;
const lines = details.exception?.description?.split('\n at ') ?? [];
const size = Math.min(
details.stackTrace?.callFrames.length ?? 0,
lines.length - 1
);
lines.splice(-size, size);
if (details.exception?.className) {
name = details.exception.className;