diff --git a/src/api/api.go b/src/api/api.go index 7c965a4..dde7a0c 100644 --- a/src/api/api.go +++ b/src/api/api.go @@ -410,20 +410,27 @@ func (a *Api) SendV2(c *gin.Context) { req.Number, req.Message, req.Recipients, req.Base64Attachments, req.Sticker, req.Mentions, req.QuoteTimestamp, req.QuoteAuthor, req.QuoteMessage, req.QuoteMentions, req.TextMode, req.EditTimestamp) if err != nil { + log.Debug("API: got an error") switch err.(type) { case *client.RateLimitErrorType: + log.Debug("Received a rate limit error") if rateLimitError, ok := err.(*client.RateLimitErrorType); ok { + log.Debug("Converted rate limit error to error type") + log.Debug("num of challenge tokens = ", len(rateLimitError.ChallengeTokens)) extendedError := errors.New(err.Error() + ". Use the attached challenge tokens to lift the rate limit restrictions via the '/v1/accounts/{number}/rate-limit-challenge' endpoint.") c.JSON(400, SendMessageError{Msg: extendedError.Error(), ChallengeTokens: rateLimitError.ChallengeTokens}) return } else { + log.Debug("Couldn't convert error to rate limit error") c.JSON(400, Error{Msg: err.Error()}) return } default: + log.Debug("Default errror") c.JSON(400, Error{Msg: err.Error()}) return } + log.Debug("shouldn't end up here") c.JSON(400, Error{Msg: err.Error()}) return } diff --git a/src/client/jsonrpc2.go b/src/client/jsonrpc2.go index 08a3000..fba1c62 100644 --- a/src/client/jsonrpc2.go +++ b/src/client/jsonrpc2.go @@ -149,6 +149,7 @@ func (r *JsonRpc2Client) getRaw(command string, account *string, args interface{ if resp.Err.Code != 0 { log.Debug("json-rpc command error code: ", resp.Err.Code) if resp.Err.Code == -5 { + log.Debug("json-rpc-client: Rate Limit Error received") var rateLimitMessage RateLimitMessage err = json.Unmarshal(resp.Err.Data, &rateLimitMessage) if err != nil { @@ -157,6 +158,7 @@ func (r *JsonRpc2Client) getRaw(command string, account *string, args interface{ challengeTokens := []string{} for _, rateLimitResult := range rateLimitMessage.Response.Results { challengeTokens = append(challengeTokens, rateLimitResult.Token) + log.Debug("json-rpc-client: Received Token: ", rateLimitResult.Token) } return "", &RateLimitErrorType{