Skip to content

Commit 3215cd8

Browse files
Marcel JacekMarcel Jacek
authored andcommitted
Update error check
1 parent 19de93b commit 3215cd8

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

stackit/internal/services/iaas/keypair/datasource.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package keypair
22

33
import (
44
"context"
5+
"errors"
56
"fmt"
67
"net/http"
78

@@ -130,7 +131,8 @@ func (r *keyPairDataSource) Read(ctx context.Context, req datasource.ReadRequest
130131

131132
keypairResp, err := r.client.GetKeyPair(ctx, name).Execute()
132133
if err != nil {
133-
oapiErr, ok := err.(*oapierror.GenericOpenAPIError) //nolint:errorlint //complaining that error.As should be used to catch wrapped errors, but this error should not be wrapped
134+
var oapiErr *oapierror.GenericOpenAPIError
135+
ok := errors.As(err, &oapiErr)
134136
if ok && oapiErr.StatusCode == http.StatusNotFound {
135137
summary := fmt.Sprintf("Key Pair with name %q does not exists", name)
136138
description := fmt.Sprintf("Key Pair with name %q cannot be found. A key pair can be added with the resource \"stackit_key_pair\"", name)

0 commit comments

Comments
 (0)