Skip to content

Commit c0b65ef

Browse files
committed
apply suggestion do not write error to already written response
1 parent d3af10f commit c0b65ef

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

routers/api/v1/misc/signing.go

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ package misc
55

66
import (
77
"errors"
8-
"fmt"
98

109
"code.gitea.io/gitea/modules/git"
1110
asymkey_service "code.gitea.io/gitea/services/asymkey"
@@ -58,13 +57,10 @@ func SigningKey(ctx *context.APIContext) {
5857
return
5958
}
6059
if format != git.KeyTypeOpenPGP {
61-
ctx.APIErrorNotFound(errors.New("SSH keys are used for signing, not GPG"))
60+
ctx.APIErrorNotFound("SSH keys are used for signing, not GPG")
6261
return
6362
}
64-
_, err = ctx.Write([]byte(content))
65-
if err != nil {
66-
ctx.APIErrorInternal(fmt.Errorf("Error writing key content %w", err))
67-
}
63+
_, _ = ctx.Write([]byte(content))
6864
}
6965

7066
// SigningKey returns the public key of the default signing key if it exists
@@ -116,8 +112,5 @@ func SigningKeySSH(ctx *context.APIContext) {
116112
ctx.APIErrorNotFound(errors.New("GPG keys are used for signing, not SSH"))
117113
return
118114
}
119-
_, err = ctx.Write([]byte(content))
120-
if err != nil {
121-
ctx.APIErrorInternal(fmt.Errorf("Error writing key content %w", err))
122-
}
115+
_, _ = ctx.Write([]byte(content))
123116
}

0 commit comments

Comments
 (0)