-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Closed
Labels
Description
This is more a suggestion than a question.
Lines 75 to 85 in 43aa457
| // returned from any handlers in the stack | |
| // cfg := fiber.Config{} | |
| // cfg.ErrorHandler = func(c *Ctx, err error) error { | |
| // code := StatusInternalServerError | |
| // if e, ok := err.(*Error); ok { | |
| // code = e.Code | |
| // } | |
| // c.Set(HeaderContentType, MIMETextPlainCharsetUTF8) | |
| // return c.Status(code).SendString(err.Error()) | |
| // } | |
| // app := fiber.New(cfg) |
this would be better to use errors.As to fit go error handling style
// ErrorHandler defines a function that will process all errors
// returned from any handlers in the stack
// cfg := fiber.Config{}
// cfg.ErrorHandler = func(c *Ctx, err error) error {
// code := StatusInternalServerError
// var e *fiber.Err
// if errors.As(err, &e) {
// code = e.Code
// }
// c.Set(HeaderContentType, MIMETextPlainCharsetUTF8)
// return c.Status(code).SendString(err.Error())
// }
// app := fiber.New(cfg)
type ErrorHandler = func(*Ctx, error) errorReactions are currently unavailable