github.com/vmware/govmomi@v0.51.0/vim25/types/fault.go (about) 1 // © Broadcom. All Rights Reserved. 2 // The term “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. 3 // SPDX-License-Identifier: Apache-2.0 4 5 package types 6 7 type HasFault interface { 8 Fault() BaseMethodFault 9 } 10 11 func IsFileNotFound(err error) bool { 12 if f, ok := err.(HasFault); ok { 13 switch f.Fault().(type) { 14 case *FileNotFound: 15 return true 16 } 17 } 18 19 return false 20 } 21 22 func IsAlreadyExists(err error) bool { 23 if f, ok := err.(HasFault); ok { 24 switch f.Fault().(type) { 25 case *AlreadyExists: 26 return true 27 } 28 } 29 30 return false 31 } 32 33 // HasLocalizedMethodFault is any type that has a LocalizedMethodFault. 34 type HasLocalizedMethodFault interface { 35 36 // GetLocalizedMethodFault returns the LocalizedMethodFault instance. 37 GetLocalizedMethodFault() *LocalizedMethodFault 38 } 39 40 // GetLocalizedMethodFault returns this LocalizedMethodFault. 41 func (f *LocalizedMethodFault) GetLocalizedMethodFault() *LocalizedMethodFault { 42 return f 43 }