Skip to content

Commit

Permalink
feat: add handling for http status code 402
Browse files Browse the repository at this point in the history
  • Loading branch information
crebsy committed Jul 10, 2024
1 parent 08c3590 commit 485ae17
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,10 @@ retry_index:
goto retry_index
}
}
if snapUrlCreds == nil {
panic(err)
}

client := http.Client{}
u, err := url.Parse(snapUrlCreds.Url)
if err != nil {
Expand Down Expand Up @@ -261,6 +265,10 @@ func getSnapUrlCreds(fileName string) (*SnapUrlResponse, error) {
return nil, err
}

if res.StatusCode == http.StatusPaymentRequired {
return nil, errors.New(string(body))
}

snapUrlResponse := SnapUrlResponse{}
err = json.Unmarshal(body, &snapUrlResponse)
if err != nil {
Expand Down

0 comments on commit 485ae17

Please sign in to comment.