Skip to content

Commit

Permalink
Merge pull request #117 from ipinfo/umar/fix-401-error
Browse files Browse the repository at this point in the history
clear error for unauthenticated request
  • Loading branch information
UmanShahzad authored Aug 11, 2022
2 parents f2ba3c4 + cfc68ee commit d340e85
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions ipinfo/cmd_asn.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package main
import (
"errors"
"fmt"
"net/http"

"github.com/fatih/color"
"github.com/ipinfo/go/v2/ipinfo"
Expand Down Expand Up @@ -67,6 +68,10 @@ func cmdASN(asn string) error {

data, err := ii.GetASNDetails(asn)
if err != nil {
iiErr, ok := err.(*ipinfo.ErrorResponse)
if ok && (iiErr.Response.StatusCode == http.StatusUnauthorized) {
return errors.New("Token does not have access to ASN API")
}
return err
}

Expand Down

0 comments on commit d340e85

Please sign in to comment.