File tree Expand file tree Collapse file tree 2 files changed +5
-10
lines changed
mmv1/third_party/terraform/tpgresource Expand file tree Collapse file tree 2 files changed +5
-10
lines changed Original file line number Diff line number Diff line change @@ -188,13 +188,9 @@ func IsQuotaError(err error) bool {
188188}
189189
190190func IsConflictError (err error ) bool {
191- if e , ok := err .(* googleapi.Error ); ok && (e .Code == 409 || e .Code == 412 ) {
192- return true
193- } else if ! ok && errwrap .ContainsType (err , & googleapi.Error {}) {
194- e := errwrap .GetType (err , & googleapi.Error {}).(* googleapi.Error )
195- if e .Code == 409 || e .Code == 412 {
196- return true
197- }
191+ var gerr * googleapi.Error
192+ if errors .As (err , & gerr ) {
193+ return gerr .Code == 409 || gerr .Code == 412
198194 }
199195 return false
200196}
Original file line number Diff line number Diff line change 66 "strings"
77 "testing"
88
9- "github.com/hashicorp/errwrap"
109 "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
1110
1211 "github.com/hashicorp/terraform-provider-google/google/tpgresource"
@@ -972,7 +971,7 @@ func TestConflictError(t *testing.T) {
972971 if ! tpgresource .IsConflictError (confErr ) {
973972 t .Error ("did not find that a 409 was a conflict error." )
974973 }
975- if ! tpgresource .IsConflictError (errwrap . Wrapf ("wrap" , confErr )) {
974+ if ! tpgresource .IsConflictError (fmt . Errorf ("wrap: %w " , confErr )) {
976975 t .Error ("did not find that a wrapped 409 was a conflict error." )
977976 }
978977 confErr = & googleapi.Error {
@@ -981,7 +980,7 @@ func TestConflictError(t *testing.T) {
981980 if ! tpgresource .IsConflictError (confErr ) {
982981 t .Error ("did not find that a 412 was a conflict error." )
983982 }
984- if ! tpgresource .IsConflictError (errwrap . Wrapf ("wrap" , confErr )) {
983+ if ! tpgresource .IsConflictError (fmt . Errorf ("wrap: %w " , confErr )) {
985984 t .Error ("did not find that a wrapped 412 was a conflict error." )
986985 }
987986 // skipping negative tests as other cases may be added later.
You can’t perform that action at this time.
0 commit comments