Skip to content

Commit

Permalink
moved err check above
Browse files Browse the repository at this point in the history
  • Loading branch information
guptado committed Feb 29, 2024
1 parent 7ddf344 commit 7e37a7e
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions digitalocean/certificate/datasource_certificate.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,14 +95,14 @@ func dataSourceDigitalOceanCertificateRead(ctx context.Context, d *schema.Resour
func FindCertificateByName(client *godo.Client, name string) (*godo.Certificate, error) {

cert, resp, err := client.Certificates.ListByName(context.Background(), name, nil)
if resp != nil && resp.StatusCode == http.StatusNotFound {
return nil, nil
}

if err != nil {
return nil, fmt.Errorf("Error retrieving certificates: %s", err)
}

if resp != nil && resp.StatusCode == http.StatusNotFound {
return nil, nil
}

if len(cert) == 0 {
return nil, fmt.Errorf("certificate not found")
}
Expand Down

0 comments on commit 7e37a7e

Please sign in to comment.