Improved error handling
This commit is contained in:
parent
3d7bd89b39
commit
d3c9ee3ac6
3 changed files with 33 additions and 8 deletions
|
@ -24,7 +24,11 @@ func TestRouter(t *testing.T) {
|
|||
})
|
||||
|
||||
s.Get("/error", func(ctx server.Context) error {
|
||||
return ctx.Error(http.StatusUnauthorized, errors.New("Not logged in"))
|
||||
return ctx.Error(http.StatusUnauthorized, "Not logged in")
|
||||
})
|
||||
|
||||
s.Get("/error2", func(ctx server.Context) error {
|
||||
return ctx.Error(http.StatusUnauthorized, "Not logged in", errors.New("Missing auth token"))
|
||||
})
|
||||
|
||||
s.Get("/reader", func(ctx server.Context) error {
|
||||
|
@ -43,6 +47,7 @@ func TestRouter(t *testing.T) {
|
|||
{URL: "/", Status: http.StatusOK, Body: "Hello"},
|
||||
{URL: "/blog/post", Status: http.StatusOK, Body: "Hello"},
|
||||
{URL: "/error", Status: http.StatusUnauthorized, Body: "Not logged in"},
|
||||
{URL: "/error2", Status: http.StatusUnauthorized, Body: "Not logged in\nMissing auth token"},
|
||||
{URL: "/not-found", Status: http.StatusNotFound, Body: http.StatusText(http.StatusNotFound)},
|
||||
{URL: "/reader", Status: http.StatusOK, Body: "Hello"},
|
||||
{URL: "/string", Status: http.StatusOK, Body: "Hello"},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue