2
Copyright (c) 2014 VMware, Inc. All Rights Reserved.
4
Licensed under the Apache License, Version 2.0 (the "License");
5
you may not use this file except in compliance with the License.
6
You may obtain a copy of the License at
8
http://www.apache.org/licenses/LICENSE-2.0
10
Unless required by applicable law or agreed to in writing, software
11
distributed under the License is distributed on an "AS IS" BASIS,
12
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
See the License for the specific language governing permissions and
14
limitations under the License.
23
"github.com/juju/govmomi/vim25/types"
26
type regularError struct {
30
func (r regularError) Error() string {
34
type soapFaultError struct {
38
func (s soapFaultError) Error() string {
39
return fmt.Sprintf("%s: %s", s.fault.Code, s.fault.String)
42
type vimFaultError struct {
43
fault types.BaseMethodFault
46
func (v vimFaultError) Error() string {
47
typ := reflect.TypeOf(v.fault)
48
for typ.Kind() == reflect.Ptr {
55
func (v vimFaultError) Fault() types.BaseMethodFault {
59
func Wrap(err error) error {
69
return WrapRegularError(err)
72
func WrapRegularError(err error) error {
73
return regularError{err}
76
func IsRegularError(err error) bool {
77
_, ok := err.(regularError)
81
func ToRegularError(err error) error {
82
return err.(regularError).err
85
func WrapSoapFault(f *Fault) error {
86
return soapFaultError{f}
89
func IsSoapFault(err error) bool {
90
_, ok := err.(soapFaultError)
94
func ToSoapFault(err error) *Fault {
95
return err.(soapFaultError).fault
98
func WrapVimFault(v types.BaseMethodFault) error {
99
return vimFaultError{v}
102
func IsVimFault(err error) bool {
103
_, ok := err.(vimFaultError)
107
func ToVimFault(err error) types.BaseMethodFault {
108
return err.(vimFaultError).fault