Skip to content

Commit

Permalink
Catch and handle invalid access token response to upload requests
Browse files Browse the repository at this point in the history
  • Loading branch information
Fizzadar committed Jul 19, 2024
1 parent ef6f441 commit b19afbe
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions messagix/mercury.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"fmt"
"mime/multipart"
"net/textproto"
"strings"

"github.com/google/go-querystring/query"
"github.com/rs/zerolog"
Expand Down Expand Up @@ -53,6 +54,9 @@ func (c *Client) SendMercuryUploadRequest(ctx context.Context, threadID int64, m

_, respBody, err := c.MakeRequest(url, "POST", h, payload, types.NONE)
if err != nil {
if strings.Contains(err.Error(), "access token is no longer valid") {
return nil, ErrTokenInvalidated
}
return nil, fmt.Errorf("failed to send MercuryUploadRequest: %v", err)
}

Expand Down

0 comments on commit b19afbe

Please sign in to comment.