github.com/volts-dev/volts@v0.0.0-20240120094013-5e9c65924106/router/recover.go (about) 1 package router 2 3 import ( 4 "bytes" 5 "fmt" 6 "runtime" 7 ) 8 9 // report error information 10 func recoverHandler(ctx IContext) { 11 buf := bytes.NewBufferString("") 12 buf.WriteString("recover: path:" + ctx.Route().Path + "\n") 13 for i := 1; ; i++ { 14 _, file, line, ok := runtime.Caller(i) 15 if !ok { 16 break 17 } 18 buf.WriteString(fmt.Sprintf(" %s %d\n", file, line)) 19 } 20 log.Err(buf.String()) 21 }