Skip to content

Commit f04f972

Browse files
authored
runtime: Print stack trace with panics (#1080)
1 parent cc8538c commit f04f972

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

runtime/applet.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"fmt"
77
"io/fs"
88
"path"
9+
"runtime/debug"
910
"slices"
1011
"strings"
1112
"testing"
@@ -291,7 +292,7 @@ func (app *Applet) RunTests(t *testing.T) {
291292
func (a *Applet) Call(ctx context.Context, callable *starlark.Function, args ...starlark.Value) (val starlark.Value, err error) {
292293
defer func() {
293294
if r := recover(); r != nil {
294-
err = fmt.Errorf("panic while running %s: %v", a.ID, r)
295+
err = fmt.Errorf("panic while running %s: %v\n%s", a.ID, r, debug.Stack())
295296
}
296297
}()
297298

@@ -357,7 +358,7 @@ func (a *Applet) load(fsys fs.FS) (err error) {
357358
func (a *Applet) ensureLoaded(fsys fs.FS, pathToLoad string, currentlyLoading ...string) (err error) {
358359
defer func() {
359360
if r := recover(); r != nil {
360-
err = fmt.Errorf("panic while executing %s: %v", a.ID, r)
361+
err = fmt.Errorf("panic while executing %s: %v\n%s", a.ID, r, debug.Stack())
361362
}
362363
}()
363364

0 commit comments

Comments
 (0)