mirror of
https://github.com/kataras/iris.git
synced 2025-12-24 05:17:03 +00:00
minor improvements
This commit is contained in:
@@ -6333,11 +6333,13 @@ func (ctx *Context) GetErrPublic() (bool, error) {
|
||||
// which recovers from a manual panic.
|
||||
type ErrPanicRecovery struct {
|
||||
ErrPrivate
|
||||
Cause interface{}
|
||||
Callers []string // file:line callers.
|
||||
Stack []byte // the full debug stack.
|
||||
RegisteredHandlers []string // file:line of all registered handlers.
|
||||
CurrentHandler string // the handler panic came from.
|
||||
Cause interface{}
|
||||
Callers []string // file:line callers.
|
||||
Stack []byte // the full debug stack.
|
||||
RegisteredHandlers []string // file:line of all registered handlers.
|
||||
CurrentHandlerFileLine string // the handler panic came from.
|
||||
CurrentHandlerName string // the handler name panic came from.
|
||||
Request string // the http dumped request.
|
||||
}
|
||||
|
||||
// Error implements the Go standard error type.
|
||||
@@ -6348,7 +6350,7 @@ func (e *ErrPanicRecovery) Error() string {
|
||||
}
|
||||
}
|
||||
|
||||
return fmt.Sprintf("%v\n%s", e.Cause, strings.Join(e.Callers, "\n"))
|
||||
return fmt.Sprintf("%v\n%s\nRequest:\n%s", e.Cause, strings.Join(e.Callers, "\n"), e.Request)
|
||||
}
|
||||
|
||||
// Is completes the internal errors.Is interface.
|
||||
@@ -6357,6 +6359,15 @@ func (e *ErrPanicRecovery) Is(err error) bool {
|
||||
return ok
|
||||
}
|
||||
|
||||
func (e *ErrPanicRecovery) LogMessage() string {
|
||||
logMessage := fmt.Sprintf("Recovered from a route's Handler('%s')\n", e.CurrentHandlerName)
|
||||
logMessage += fmt.Sprint(e.Request)
|
||||
logMessage += fmt.Sprintf("%s\n", e.Cause)
|
||||
logMessage += fmt.Sprintf("%s\n", strings.Join(e.Callers, "\n"))
|
||||
|
||||
return logMessage
|
||||
}
|
||||
|
||||
// IsErrPanicRecovery reports whether the given "err" is a type of ErrPanicRecovery.
|
||||
func IsErrPanicRecovery(err error) (*ErrPanicRecovery, bool) {
|
||||
if err == nil {
|
||||
|
||||
Reference in New Issue
Block a user