MCPcopy
hub / github.com/gofiber/fiber / Test_Router_Handler_Catch_Error

Function Test_Router_Handler_Catch_Error

router_test.go:774–791  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

772}
773
774func Test_Router_Handler_Catch_Error(t *testing.T) {
775 t.Parallel()
776
777 app := New()
778 app.config.ErrorHandler = func(_ Ctx, _ error) error {
779 return errors.New("fake error")
780 }
781
782 app.Get("/", func(_ Ctx) error {
783 return ErrForbidden
784 })
785
786 c := &fasthttp.RequestCtx{}
787
788 app.Handler()(c)
789
790 require.Equal(t, StatusInternalServerError, c.Response.Header.StatusCode())
791}
792
793func Test_Router_NotFound(t *testing.T) {
794 t.Parallel()

Callers

nothing calls this directly

Calls 5

HandlerMethod · 0.80
NewFunction · 0.70
NewMethod · 0.65
GetMethod · 0.65
StatusCodeMethod · 0.45

Tested by

no test coverage detected