Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | 5x 5x 5x 5x 5x 5x | export function safeErrorLogMetadata(error: unknown): string {
const errorType = error instanceof Error ? error.name : typeof error;
let messageBytes = 0;
if (error instanceof Error) {
messageBytes = Buffer.byteLength(error.message);
} else Eif (typeof error === "string") {
messageBytes = Buffer.byteLength(error);
}
const errorCode = error instanceof Error && "code" in error && typeof error.code === "string"
? " code=" + error.code
: "";
return errorType + errorCode + ", " + messageBytes + " diagnostic bytes";
}
export function safeErrorStackFrames(error: unknown): string {
if (!(error instanceof Error) || !error.stack) return "";
return error.stack.split("\n").slice(1, 6).join("\n");
}
|