Skip to content

Commit

Permalink
Capture stack in panic
Browse files Browse the repository at this point in the history
  • Loading branch information
tonyhb committed Sep 16, 2024
1 parent 6d204d0 commit 30571d2
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"net/url"
"os"
"reflect"
"runtime/debug"
"sync"
"time"

Expand Down Expand Up @@ -1117,7 +1118,8 @@ func invoke(ctx context.Context, sf ServableFunction, input *sdkrequest.Request)
if _, ok := r.(step.ControlHijack); ok {
return
}
panickErr = fmt.Errorf("function panicked: %v", r)
stack := string(debug.Stack())
panickErr = fmt.Errorf("function panicked: %v. stack:\n%s", r, stack)
}
}()

Expand Down

0 comments on commit 30571d2

Please sign in to comment.