Skip to content

Commit

Permalink
optimize: add more detail error message in serverErrorHandler
Browse files Browse the repository at this point in the history
  • Loading branch information
li-jin-gou committed Dec 10, 2022
1 parent affa759 commit 2f184f8
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions app.go
Expand Up @@ -1020,6 +1020,7 @@ func (app *App) ErrorHandler(ctx *Ctx, err error) error {
// errors before calling the application's error handler method.
func (app *App) serverErrorHandler(fctx *fasthttp.RequestCtx, err error) {
c := app.AcquireCtx(fctx)
oldErr := err
if _, ok := err.(*fasthttp.ErrSmallBuffer); ok {
err = ErrRequestHeaderFieldsTooLarge
} else if netErr, ok := err.(*net.OpError); ok && netErr.Timeout() {
Expand All @@ -1033,6 +1034,7 @@ func (app *App) serverErrorHandler(fctx *fasthttp.RequestCtx, err error) {
} else {
err = ErrBadRequest
}
err.(*Error).Message = oldErr.Error()

if catch := app.ErrorHandler(c, err); catch != nil {
_ = c.SendStatus(StatusInternalServerError)
Expand Down

0 comments on commit 2f184f8

Please sign in to comment.