diff options
Diffstat (limited to 'routers/api/v1/repo/notes.go')
-rw-r--r-- | routers/api/v1/repo/notes.go | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/routers/api/v1/repo/notes.go b/routers/api/v1/repo/notes.go index 8fec844cc4..87efb1caf2 100644 --- a/routers/api/v1/repo/notes.go +++ b/routers/api/v1/repo/notes.go @@ -4,7 +4,7 @@ package repo import ( - "fmt" + "errors" "net/http" "code.gitea.io/gitea/modules/git" @@ -54,7 +54,7 @@ func GetNote(ctx *context.APIContext) { sha := ctx.PathParam("sha") if !git.IsValidRefPattern(sha) { - ctx.Error(http.StatusUnprocessableEntity, "no valid ref or sha", fmt.Sprintf("no valid ref or sha: %s", sha)) + ctx.APIError(http.StatusUnprocessableEntity, "no valid ref or sha: "+sha) return } getNote(ctx, sha) @@ -62,16 +62,16 @@ func GetNote(ctx *context.APIContext) { func getNote(ctx *context.APIContext, identifier string) { if ctx.Repo.GitRepo == nil { - ctx.InternalServerError(fmt.Errorf("no open git repo")) + ctx.APIErrorInternal(errors.New("no open git repo")) return } commitID, err := ctx.Repo.GitRepo.ConvertToGitID(identifier) if err != nil { if git.IsErrNotExist(err) { - ctx.NotFound(err) + ctx.APIErrorNotFound(err) } else { - ctx.Error(http.StatusInternalServerError, "ConvertToSHA1", err) + ctx.APIErrorInternal(err) } return } @@ -79,10 +79,10 @@ func getNote(ctx *context.APIContext, identifier string) { var note git.Note if err := git.GetNote(ctx, ctx.Repo.GitRepo, commitID.String(), ¬e); err != nil { if git.IsErrNotExist(err) { - ctx.NotFound(identifier) + ctx.APIErrorNotFound("commit doesn't exist: " + identifier) return } - ctx.Error(http.StatusInternalServerError, "GetNote", err) + ctx.APIErrorInternal(err) return } @@ -96,7 +96,7 @@ func getNote(ctx *context.APIContext, identifier string) { Files: files, }) if err != nil { - ctx.Error(http.StatusInternalServerError, "ToCommit", err) + ctx.APIErrorInternal(err) return } apiNote := api.Note{Message: string(note.Message), Commit: cmt} |