Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions messaging/messaging.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,12 @@ var (

fcmErrorCodes = map[string]string{
"INVALID_ARGUMENT": "request contains an invalid argument; code: invalid-argument",
"NOT_FOUND": "request contains an invalid argument; code: registration-token-not-registered",
"PERMISSION_DENIED": "client does not have permission to perform the requested operation; code: authentication-error",
"RESOURCE_EXHAUSTED": "messaging service quota exceeded; code: message-rate-exceeded",
"UNAUTHENTICATED": "client failed to authenticate; code: authentication-error",
"UNREGISTERED": "app instance has been unregistered; code: registration-token-not-registered",
"SENDER_ID_MISMATCH": "sender id does not match regisration token; code: authentication-error",
"QUOTA_EXCEEDED": "messaging service quota exceeded; code: message-rate-exceeded",
"APNS_AUTH_ERROR": "apns certificate or auth key was invalid; code: authentication-error",
"UNAVAILABLE": "backend servers are temporarily unavailable; code: server-unavailable",
"INTERNAL": "back servers encountered an unknown internl error; code: internal-error",
}

iidErrorCodes = map[string]string{
Expand Down Expand Up @@ -416,7 +417,7 @@ func (c *Client) makeSendRequest(ctx context.Context, req *fcmRequest) (string,
json.Unmarshal(resp.Body, &fe) // ignore any json parse errors at this level
msg := fcmErrorCodes[fe.Error.Status]
if msg == "" {
msg = fmt.Sprintf("client encountered an unknown error; response: %s", string(resp.Body))
msg = fmt.Sprintf("server responded with an unknown error; response: %s", string(resp.Body))
}
return "", fmt.Errorf("http error status: %d; reason: %s", resp.Status, msg)
}
Expand Down
4 changes: 2 additions & 2 deletions messaging/messaging_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -627,15 +627,15 @@ func TestSendError(t *testing.T) {
}{
{
resp: "{}",
want: "http error status: 500; reason: client encountered an unknown error; response: {}",
want: "http error status: 500; reason: server responded with an unknown error; response: {}",
},
{
resp: "{\"error\": {\"status\": \"INVALID_ARGUMENT\", \"message\": \"test error\"}}",
want: "http error status: 500; reason: request contains an invalid argument; code: invalid-argument",
},
{
resp: "not json",
want: "http error status: 500; reason: client encountered an unknown error; response: not json",
want: "http error status: 500; reason: server responded with an unknown error; response: not json",
},
}
for _, tc := range cases {
Expand Down