Skip to content
This repository was archived by the owner on Aug 5, 2024. It is now read-only.

Commit 5349035

Browse files
committed
improve exception handling
1 parent dce6633 commit 5349035

File tree

2 files changed

+15
-12
lines changed

2 files changed

+15
-12
lines changed

src/wssk.ts

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,7 @@ export class ConnectedDevice {
525525
for (const l of logs) {
526526
let m = /DevS-SHA256:\s+([a-f0-9]{64})/.exec(l)
527527
if (m) sha = m[1].toLowerCase()
528-
m = /^\* Exception:\s*(\S+)/.exec(l)
528+
m = /^[\*!] Exception:\s*(\S+)/.exec(l)
529529
if (m) {
530530
startIdx = idx
531531
exnName = m[1]
@@ -546,26 +546,29 @@ export class ConnectedDevice {
546546
}
547547
}
548548

549-
if (this.lastDbgInfo) {
550-
logs = logs.map(l =>
551-
parseStackFrame(this.lastDbgInfo, l).markedLine.replace(
552-
/\u001b\[[\d;]+m/g,
553-
""
554-
)
549+
logs = logs.map(l =>
550+
parseStackFrame(this.lastDbgInfo, l).markedLine.replace(
551+
/\u001b\[[\d;]+m/g,
552+
""
555553
)
556-
}
554+
)
557555

558-
const stack = logs.slice(startIdx).filter(l => l.startsWith("*"))
556+
const stack = logs
557+
.slice(startIdx)
558+
.filter(l => l.startsWith("*") || l.startsWith("!"))
559+
.map(l => l.slice(1))
559560
let message = ""
560561
for (const l of stack) {
561-
const m = /^\*\s+message: (.*)/.exec(l)
562+
const m = /^\s+message: (.*)/.exec(l)
562563
if (m) message = m[1]
563564
}
564565

565566
const exn: Error = {
566567
name: exnName,
567568
message,
568-
stack: stack.join("\n"),
569+
stack:
570+
`${exnName}: ${message}\n` +
571+
stack.filter(l => /^\s*at /.test(l)).join("\n"),
569572
}
570573

571574
return {

0 commit comments

Comments
 (0)