Skip to content

Commit 0080250

Browse files
author
cuiko tang
authored
Merge pull request #28 from cuiko/fix/rpc-user-creator-mapping
fix(status): Map USER_CREATOR to a friendly usage error
2 parents ec0df05 + 0631141 commit 0080250

2 files changed

Lines changed: 2 additions & 1 deletion

File tree

internal/program/status/rpc.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ var rpcErrors = map[string]rpcClass{
4343
// "Bad request argument" family -> usage / exit 2.
4444
tg.ErrHideRequesterMissing: {CodeUsage, 2, "no pending join request from this user"},
4545
tg.ErrParticipantIDInvalid: {CodeUsage, 2, "that user can't be the target of this action (e.g. the group creator)"},
46+
tg.ErrUserCreator: {CodeUsage, 2, "this action isn't allowed on the group/channel creator"},
4647
tg.ErrFileReferenceExpired: {CodeUsage, 2, "sticker reference expired; run `tg msg sticker list` again for a fresh ref"},
4748
tg.ErrFileReferenceInvalid: {CodeUsage, 2, "sticker reference is no longer valid; run `tg msg sticker list` again for a fresh ref"},
4849
}

internal/program/status/rpc_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ func TestRPC_ClassifiesForbiddenFamily(t *testing.T) {
3232
}
3333

3434
func TestRPC_ClassifiesUsageFamily(t *testing.T) {
35-
for _, typ := range []string{"HIDE_REQUESTER_MISSING", "PARTICIPANT_ID_INVALID"} {
35+
for _, typ := range []string{"HIDE_REQUESTER_MISSING", "PARTICIPANT_ID_INVALID", "USER_CREATOR"} {
3636
err := rpcErr(typ, 400)
3737
require.Equal(t, CodeUsage, Code(err), typ)
3838
require.Equal(t, 2, MapExitCode(err), typ)

0 commit comments

Comments
 (0)