Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

optimize: add more detail error message in serverErrorHandler #2267

Merged
merged 1 commit into from Dec 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion app.go
Expand Up @@ -1031,7 +1031,7 @@ func (app *App) serverErrorHandler(fctx *fasthttp.RequestCtx, err error) {
} else if strings.Contains(err.Error(), "timeout") {
err = ErrRequestTimeout
} else {
err = ErrBadRequest
err = NewError(StatusBadRequest, err.Error())
}

if catch := app.ErrorHandler(c, err); catch != nil {
Expand Down
10 changes: 10 additions & 0 deletions app_test.go
Expand Up @@ -245,6 +245,16 @@ func Test_App_ErrorHandler_RouteStack(t *testing.T) {
utils.AssertEqual(t, "1: USE error", string(body))
}

func Test_App_serverErrorHandler_Internal_Error(t *testing.T) {
app := New()
msg := "test err"
c := app.AcquireCtx(&fasthttp.RequestCtx{})
defer app.ReleaseCtx(c)
app.serverErrorHandler(c.fasthttp, errors.New(msg))
utils.AssertEqual(t, string(c.fasthttp.Response.Body()), msg)
utils.AssertEqual(t, c.fasthttp.Response.StatusCode(), StatusBadRequest)
}

func Test_App_Nested_Params(t *testing.T) {
app := New()

Expand Down