Source File
recover.go
Belonging Package
github.com/gofiber/fiber/v2/middleware/recover
package recover //nolint:predeclared // TODO: Rename to some non-builtinimport ()func defaultStackTraceHandler( *fiber.Ctx, interface{}) {_, _ = os.Stderr.WriteString(fmt.Sprintf("panic: %v\n%s\n", , debug.Stack())) //nolint:errcheck // This will never fail}// New creates a new middleware handlerfunc ( ...Config) fiber.Handler {// Set default config:= configDefault(...)// Return new handlerreturn func( *fiber.Ctx) ( error) { //nolint:nonamedreturns // Uses recover() to overwrite the error// Don't execute middleware if Next returns trueif .Next != nil && .Next() {return .Next()}// Catch panicsdefer func() {if := recover(); != nil {if .EnableStackTrace {.StackTraceHandler(, )}var boolif , = .(error); ! {// Set error that will call the global error handler= fmt.Errorf("%v", )}}}()// Return err if exist, else move to next handlerreturn .Next()}}
![]() |
The pages are generated with Golds v0.6.7. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds. |