mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-05-16 15:02:43 +00:00
unified API error response
This commit is contained in:
parent
b1941f1da1
commit
aff49b1c9e
13 changed files with 61 additions and 67 deletions
|
@ -8,7 +8,6 @@ import (
|
|||
api "github.com/gogits/go-gogs-client"
|
||||
|
||||
"github.com/gogits/gogs/models"
|
||||
"github.com/gogits/gogs/modules/base"
|
||||
"github.com/gogits/gogs/modules/middleware"
|
||||
)
|
||||
|
||||
|
@ -16,7 +15,7 @@ import (
|
|||
func ListAccessTokens(ctx *middleware.Context) {
|
||||
tokens, err := models.ListAccessTokens(ctx.User.Id)
|
||||
if err != nil {
|
||||
ctx.JSON(500, &base.ApiJsonErr{"ListAccessTokens: " + err.Error(), base.DOC_URL})
|
||||
ctx.APIError(500, "ListAccessTokens", err)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -38,7 +37,7 @@ func CreateAccessToken(ctx *middleware.Context, form CreateAccessTokenForm) {
|
|||
Name: form.Name,
|
||||
}
|
||||
if err := models.NewAccessToken(t); err != nil {
|
||||
ctx.JSON(500, &base.ApiJsonErr{"NewAccessToken: " + err.Error(), base.DOC_URL})
|
||||
ctx.APIError(500, "NewAccessToken", err)
|
||||
return
|
||||
}
|
||||
ctx.JSON(201, &api.AccessToken{t.Name, t.Sha1})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue