From 9e9ca66467116e9079a2639c00e9e623aca23015 Mon Sep 17 00:00:00 2001 From: ᴜɴᴋɴᴡᴏɴ Date: Mon, 16 Mar 2020 01:22:27 +0800 Subject: refactor: unify error handling in routing layer --- internal/route/api/v1/user/app.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'internal/route/api/v1/user/app.go') diff --git a/internal/route/api/v1/user/app.go b/internal/route/api/v1/user/app.go index fdf11c09..99a422cc 100644 --- a/internal/route/api/v1/user/app.go +++ b/internal/route/api/v1/user/app.go @@ -17,7 +17,7 @@ import ( func ListAccessTokens(c *context.APIContext) { tokens, err := db.ListAccessTokens(c.User.ID) if err != nil { - c.ServerError("ListAccessTokens", err) + c.Error(err, "list access tokens") return } @@ -35,9 +35,9 @@ func CreateAccessToken(c *context.APIContext, form api.CreateAccessTokenOption) } if err := db.NewAccessToken(t); err != nil { if errors.IsAccessTokenNameAlreadyExist(err) { - c.Error(http.StatusUnprocessableEntity, "", err) + c.ErrorStatus(http.StatusUnprocessableEntity, err) } else { - c.ServerError("NewAccessToken", err) + c.Error(err, "new access token") } return } -- cgit v1.2.3