Skip to content

Commit

Permalink
Suppress 404 errors, treat as non-existence of resource
Browse files Browse the repository at this point in the history
Signed-off-by: Brendan Devenney <[email protected]>
  • Loading branch information
devenney-form3 committed Sep 5, 2019
1 parent 6affce0 commit c2ae260
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions auth0/auth0_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ func (authClient *AuthClient) GetUserById(id string) (*User, error) {

resp, body, errs := gorequest.New().Get(authClient.config.apiUri+"users/"+id).Set("Authorization", authClient.config.getAuthenticationHeader()).End()

if resp.StatusCode >= 400 {
if resp.StatusCode >= 400 && resp.StatusCode != 404 {
return nil, fmt.Errorf("bad status code (%d): %s", resp.StatusCode, body)
}

Expand Down Expand Up @@ -206,7 +206,7 @@ func (authClient *AuthClient) GetClientById(id string) (*Client, error) {

resp, body, errs := gorequest.New().Get(authClient.config.apiUri+"clients/"+id).Set("Authorization", authClient.config.getAuthenticationHeader()).End()

if resp.StatusCode >= 400 {
if resp.StatusCode >= 400 && resp.StatusCode != 404 {
return nil, fmt.Errorf("bad status code (%d): %s", resp.StatusCode, body)
}

Expand Down Expand Up @@ -290,7 +290,7 @@ func (authClient *AuthClient) GetApiById(id string) (*Api, error) {

resp, body, errs := gorequest.New().Get(authClient.config.apiUri+"resource-servers/"+id).Set("Authorization", authClient.config.getAuthenticationHeader()).End()

if resp.StatusCode >= 400 {
if resp.StatusCode >= 400 && resp.StatusCode != 404 {
return nil, fmt.Errorf("bad status code (%d): %s", resp.StatusCode, body)
}

Expand Down Expand Up @@ -384,7 +384,7 @@ func (authClient *AuthClient) GetClientGrantByClientIdAndAudience(clientId strin
Query(queryParams).Set("Authorization", authClient.config.getAuthenticationHeader()).
End()

if resp.StatusCode >= 400 {
if resp.StatusCode >= 400 && resp.StatusCode != 404 {
return nil, fmt.Errorf("bad status code (%d): %s", resp.StatusCode, body)
}

Expand Down

0 comments on commit c2ae260

Please sign in to comment.