Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

runtime: Print stack trace with panics #1080

Merged
merged 1 commit into from
Jul 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading