Skip to content

Commit

Permalink
Add possible fix of error handling (#185)
Browse files Browse the repository at this point in the history
* Add possible fix of error handling

* Improved error message
  • Loading branch information
andriisoldatenko authored and schnie committed Mar 4, 2019
1 parent ee102f9 commit 49d4ba5
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion houston/houston.go
Expand Up @@ -12,6 +12,10 @@ import (
"github.com/astronomer/astro-cli/pkg/httputil"
)


var PermissionsError = errors.New("You do not have the appropriate permissions for that")


// Client containers the logger and HTTPClient used to communicate with the HoustonAPI
type Client struct {
HTTPClient *httputil.HTTPClient
Expand Down Expand Up @@ -85,7 +89,11 @@ func (c *Client) Do(doOpts httputil.DoOptions) (*HoustonResponse, error) {

// Houston Specific Errors
if decode.Errors != nil {
return nil, errors.New(decode.Errors[0].Message)
err = errors.New(decode.Errors[0].Message)
if err.Error() == PermissionsError.Error() {
return nil, errors.New("Your token has expired. Please log in again.")
}
return nil, err
}

return &decode, nil
Expand Down

0 comments on commit 49d4ba5

Please sign in to comment.