Skip to content

Commit

Permalink
log panic stack on recover
Browse files Browse the repository at this point in the history
  • Loading branch information
erichulburd committed Apr 12, 2022
1 parent 54bd7aa commit 62e07c7
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion enforcer.go
Expand Up @@ -17,6 +17,7 @@ package casbin
import (
"errors"
"fmt"
"runtime/debug"
"strings"

"github.com/Knetic/govaluate"
Expand Down Expand Up @@ -468,7 +469,7 @@ func NewEnforceContext(suffix string) EnforceContext {
func (e *Enforcer) enforce(matcher string, explains *[]string, rvals ...interface{}) (ok bool, err error) {
defer func() {
if r := recover(); r != nil {
err = fmt.Errorf("panic: %+v", r)
err = fmt.Errorf("panic: %v\n%s", r, debug.Stack())
}
}()

Expand Down

0 comments on commit 62e07c7

Please sign in to comment.