Skip to content

Commit

Permalink
fix: allow to return nil from custom error handler (#382)
Browse files Browse the repository at this point in the history
  • Loading branch information
martinvibes authored Feb 3, 2025
1 parent b2965ee commit 57eab5b
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions engine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,19 @@ func TestWithErrorHandler(t *testing.T) {
errResponse := e.ErrorHandler(err)
require.Equal(t, "Not Found", errResponse.Error())
})

t.Run("nil returning handler", func(t *testing.T) {
e := NewEngine(
WithErrorHandler(func(err error) error {
return nil
}),
)
err := NotFoundError{
Err: errors.New("Not Found"),
}
errResponse := e.ErrorHandler(err)
require.Nil(t, errResponse, "error handler can return nil, which might lead to unexpected behavior")
})
}

func TestWithRequestContentType(t *testing.T) {
Expand Down

0 comments on commit 57eab5b

Please sign in to comment.