recover.go — fiber Source File
Architecture documentation for recover.go, a go file in the fiber codebase. 1 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 8dd0510f_dab1_1238_ceb0_f0d4d311041e["recover.go"] adf3d4e8_4d86_86c1_e6cc_281d7b4104af["fmt"] 8dd0510f_dab1_1238_ceb0_f0d4d311041e --> adf3d4e8_4d86_86c1_e6cc_281d7b4104af style 8dd0510f_dab1_1238_ceb0_f0d4d311041e fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
package recover //nolint:predeclared // TODO: Rename to some non-builtin
import (
"fmt"
"os"
"runtime/debug"
"github.com/gofiber/fiber/v3"
)
func defaultStackTraceHandler(_ fiber.Ctx, e any) {
fmt.Fprintf(os.Stderr, "panic: %v\n\n%s\n", e, debug.Stack())
}
// New creates a new middleware handler
func New(config ...Config) fiber.Handler {
// Set default config
cfg := configDefault(config...)
// Return new handler
return func(c fiber.Ctx) (err error) { //nolint:nonamedreturns // Uses recover() to overwrite the error
// Don't execute middleware if Next returns true
if cfg.Next != nil && cfg.Next(c) {
return c.Next()
}
// Catch panics
defer func() {
if r := recover(); r != nil {
if cfg.EnableStackTrace {
cfg.StackTraceHandler(c, r)
}
var ok bool
if err, ok = r.(error); !ok {
// Set error that will call the global error handler
err = fmt.Errorf("%v", r)
}
}
}()
// Return err if exist, else move to next handler
return c.Next()
}
}
Domain
Subdomains
Functions
Classes
Dependencies
- fmt
Source
Frequently Asked Questions
What does recover.go do?
recover.go is a source file in the fiber codebase, written in go. It belongs to the FiberCore domain, Adapters subdomain.
What functions are defined in recover.go?
recover.go defines 2 function(s): New, defaultStackTraceHandler.
What does recover.go depend on?
recover.go imports 1 module(s): fmt.
Where is recover.go in the architecture?
recover.go is located at middleware/recover/recover.go (domain: FiberCore, subdomain: Adapters, directory: middleware/recover).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free