Skip to content

Commit

Permalink
fix: show message when deleting a resource that doesnt exist (#2589)
Browse files Browse the repository at this point in the history
* show message when deleting a resource that doesnt exist

* Update cli/utils/api.go

Co-authored-by: Daniel Baptista Dias <danielbdias@users.noreply.github.com>

---------

Co-authored-by: Daniel Baptista Dias <danielbdias@users.noreply.github.com>
  • Loading branch information
mathnogueira and danielbdias committed May 25, 2023
1 parent f0ac0ee commit b87a3ff
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions cli/utils/api.go
Expand Up @@ -138,8 +138,16 @@ func (resourceClient ResourceClient) Delete(ctx context.Context, ID string) erro
return fmt.Errorf("could not delete resource: %w", err)
}

_, err = resourceClient.Client.Do(request)
return err
response, err := resourceClient.Client.Do(request)
if err != nil {
return err
}

if response.StatusCode == http.StatusNotFound {
return fmt.Errorf(`Resource %s with ID %s not found" was found`, resourceClient.ResourceType, ID)
}

return nil
}

func (resourceClient ResourceClient) Get(ctx context.Context, id string) (*file.File, error) {
Expand Down

0 comments on commit b87a3ff

Please sign in to comment.