Skip to content

Commit

Permalink
♻️ refactor: default error handler & example (gofiber#1941)
Browse files Browse the repository at this point in the history
* ♻️ refactor: default error handler & example

* ♻️ refactor: default error handler & example
  • Loading branch information
efectn authored and trim21 committed Aug 15, 2022
1 parent ba7b98a commit ca3d37d
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions app.go
Expand Up @@ -76,7 +76,8 @@ type Storage interface {
// cfg := fiber.Config{}
// cfg.ErrorHandler = func(c *Ctx, err error) error {
// code := StatusInternalServerError
// if e, ok := err.(*Error); ok {
// var e *fiber.Error
// if errors.As(err, &e) {
// code = e.Code
// }
// c.Set(HeaderContentType, MIMETextPlainCharsetUTF8)
Expand Down Expand Up @@ -433,7 +434,8 @@ const (
// DefaultErrorHandler that process return errors from handlers
var DefaultErrorHandler = func(c *Ctx, err error) error {
code := StatusInternalServerError
if e, ok := err.(*Error); ok {
var e *Error
if errors.As(err, &e) {
code = e.Code
}
c.Set(HeaderContentType, MIMETextPlainCharsetUTF8)
Expand Down

0 comments on commit ca3d37d

Please sign in to comment.