Skip to content

Commit

Permalink
♻️ refactor: default error handler & example (#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 committed Jul 4, 2022
1 parent e58ad6b commit 29be233
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 29be233

Please sign in to comment.