Skip to content

Commit

Permalink
runtime: Print stack trace with panics (#1080)
Browse files Browse the repository at this point in the history
  • Loading branch information
rohansingh authored Jul 4, 2024
1 parent cc8538c commit f04f972
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions runtime/applet.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"fmt"
"io/fs"
"path"
"runtime/debug"
"slices"
"strings"
"testing"
Expand Down Expand Up @@ -291,7 +292,7 @@ func (app *Applet) RunTests(t *testing.T) {
func (a *Applet) Call(ctx context.Context, callable *starlark.Function, args ...starlark.Value) (val starlark.Value, err error) {
defer func() {
if r := recover(); r != nil {
err = fmt.Errorf("panic while running %s: %v", a.ID, r)
err = fmt.Errorf("panic while running %s: %v\n%s", a.ID, r, debug.Stack())
}
}()

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

Expand Down

0 comments on commit f04f972

Please sign in to comment.