Skip to content

Commit 963b42a

Browse files
authored
Change panic handler to log the WASM stacktrace (#31)
1 parent 4422dae commit 963b42a

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

wasm/main.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ package main
2323

2424
import (
2525
"fmt"
26+
"runtime/debug"
2627
"syscall/js"
2728

2829
"github.com/elastic/ottl-playground/wasm/internal"
@@ -34,7 +35,7 @@ func handlePanic() {
3435
}()
3536
if r := recover(); r != nil {
3637
js.Global().Call("wasmPanicHandler", fmt.Sprintf("An error occurred in the WASM module: %v", r))
37-
js.Global().Get("console").Call("error", "stack trace:", js.Global().Get("Error").New().Get("stack").String())
38+
js.Global().Get("console").Call("error", fmt.Sprintf("[WASM] %v %s", r, string(debug.Stack())))
3839
}
3940
}
4041

0 commit comments

Comments
 (0)