Skip to content

Commit 52890fd

Browse files
committed
Provided better feedback when the cookie is expired
1 parent a3270b4 commit 52890fd

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

sdk/sdk-get-core.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"encoding/json"
88
"errors"
99
"fmt"
10+
"golang.org/x/net/html"
1011
"io"
1112
"io/ioutil"
1213
"strconv"
@@ -254,7 +255,14 @@ func (s *Sdk) getUrlBody(url string, fnCall string, jsonBody bool, retriesLeft i
254255
var out bytes.Buffer
255256
jErr := json.Indent(&out, b, "", " ")
256257
if jErr != nil {
257-
msg := fmt.Sprintf("%s -> json parsing error: %s", fnCall, jErr.Error())
258+
var msg string
259+
_, err := html.Parse(bytes.NewReader(b))
260+
if err == nil {
261+
msg = fmt.Sprintf("%s -> expected json and got html from gog api call, either the gog api contract changed or more likely your cookie is expired", fnCall)
262+
} else {
263+
msg = fmt.Sprintf("%s -> json parsing error: %s", fnCall, jErr.Error())
264+
}
265+
258266
return BodyReply{
259267
Body: nil,
260268
FinalUrl: reply.FinalUrl,

0 commit comments

Comments
 (0)