File tree Expand file tree Collapse file tree 2 files changed +10
-5
lines changed
mmv1/third_party/terraform/tpgresource Expand file tree Collapse file tree 2 files changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -188,9 +188,13 @@ func IsQuotaError(err error) bool {
188188}
189189
190190func IsConflictError (err error ) bool {
191- var gerr * googleapi.Error
192- if errors .As (err , & gerr ) {
193- return gerr .Code == 409 || gerr .Code == 412
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+ }
194198 }
195199 return false
196200}
Original file line number Diff line number Diff line change 66 "strings"
77 "testing"
88
9+ "github.com/hashicorp/errwrap"
910 "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
1011
1112 "github.com/hashicorp/terraform-provider-google/google/tpgresource"
@@ -971,7 +972,7 @@ func TestConflictError(t *testing.T) {
971972 if ! tpgresource .IsConflictError (confErr ) {
972973 t .Error ("did not find that a 409 was a conflict error." )
973974 }
974- if ! tpgresource .IsConflictError (fmt . Errorf ("wrap: %w " , confErr )) {
975+ if ! tpgresource .IsConflictError (errwrap . Wrapf ("wrap" , confErr )) {
975976 t .Error ("did not find that a wrapped 409 was a conflict error." )
976977 }
977978 confErr = & googleapi.Error {
@@ -980,7 +981,7 @@ func TestConflictError(t *testing.T) {
980981 if ! tpgresource .IsConflictError (confErr ) {
981982 t .Error ("did not find that a 412 was a conflict error." )
982983 }
983- if ! tpgresource .IsConflictError (fmt . Errorf ("wrap: %w " , confErr )) {
984+ if ! tpgresource .IsConflictError (errwrap . Wrapf ("wrap" , confErr )) {
984985 t .Error ("did not find that a wrapped 412 was a conflict error." )
985986 }
986987 // skipping negative tests as other cases may be added later.
You can’t perform that action at this time.
0 commit comments