Skip to content

Commit

Permalink
fix: validate if server returns 404 error on inexisting id in demo an…
Browse files Browse the repository at this point in the history
…d polling profile (#2227)

* validate if server returns 404 error on inexisting id

* apply same fix for polling profile
  • Loading branch information
mathnogueira committed Mar 21, 2023
1 parent 340f1b4 commit 9718e55
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions cli/actions/demo.go
Expand Up @@ -100,6 +100,10 @@ func (demo demoActions) update(ctx context.Context, file file.File, ID string) e
}

defer resp.Body.Close()
if resp.StatusCode == http.StatusNotFound {
return fmt.Errorf("demo id doesn't exist on server. Remove it from the definition file and try again")
}

if resp.StatusCode == http.StatusUnprocessableEntity {
// validation error
body, err := ioutil.ReadAll(resp.Body)
Expand Down
4 changes: 4 additions & 0 deletions cli/actions/polling.go
Expand Up @@ -100,6 +100,10 @@ func (polling pollingActions) update(ctx context.Context, file file.File, ID str
}

defer resp.Body.Close()
if resp.StatusCode == http.StatusNotFound {
return fmt.Errorf("polling profile id doesn't exist on server. Remove it from the definition file and try again")
}

if resp.StatusCode == http.StatusUnprocessableEntity {
// validation error
body, err := ioutil.ReadAll(resp.Body)
Expand Down

0 comments on commit 9718e55

Please sign in to comment.