diff options
author | ᴜɴᴋɴᴡᴏɴ <u@gogs.io> | 2020-03-16 01:22:27 +0800 |
---|---|---|
committer | ᴜɴᴋɴᴡᴏɴ <u@gogs.io> | 2020-03-16 01:22:27 +0800 |
commit | 9e9ca66467116e9079a2639c00e9e623aca23015 (patch) | |
tree | dacdef5392608ff7107e4dd498959d4899e13e54 /internal/route/api/v1/user/app.go | |
parent | 82ff0c5852f29daa5f95d965fd50665581e7ea3c (diff) |
refactor: unify error handling in routing layer
Diffstat (limited to 'internal/route/api/v1/user/app.go')
-rw-r--r-- | internal/route/api/v1/user/app.go | 6 |
1 files changed, 3 insertions, 3 deletions
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 } |