-
Notifications
You must be signed in to change notification settings - Fork 0
/
errors.go
36 lines (30 loc) · 954 Bytes
/
errors.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// govplus is a basic govmomi helper library for using vSphere API
// This file contains error related functions and definitions
//
// Author: Tesifonte Belda
// License: The MIT License (MIT)
package govplus
import (
"context"
"errors"
"net"
)
// Common raised errors
var (
ErrorNoClient = errors.New("no vCenter client, no session has been opened")
ErrorNotVC = errors.New("endpoint does not look like a vCenter")
ErrorURLParsing = errors.New("error parsing URL for vcenter")
ErrorURLNil = errors.New("vcenter URL should not be nil")
)
// IsHardQueryError returns false if error is light and we may continue quering
func IsHardQueryError(err error) (bool, error) {
if errors.Is(err, context.Canceled) || errors.Is(err, context.DeadlineExceeded) {
return true, err
}
var dnsError *net.DNSError
var opError *net.OpError
if errors.As(err, &dnsError) || errors.As(err, &opError) {
return true, err
}
return false, err
}