forked from cloudfoundry/bosh-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
errors.go
52 lines (42 loc) · 929 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package cloud
import (
"fmt"
)
const (
VMNotFoundError = "Bosh::Clouds::VMNotFound"
DiskNotFoundError = "Bosh::Clouds::DiskNotFound"
StemcellNotFoundError = "Bosh::Clouds::StemcellNotFound"
NotImplementedError = "Bosh::Clouds::NotImplemented"
)
type Error interface {
error
Method() string
Type() string
Message() string
OkToRetry() bool
}
type cpiError struct {
method string
cmdError CmdError
}
func NewCPIError(method string, cmdError CmdError) Error {
return cpiError{
method: method,
cmdError: cmdError,
}
}
func (e cpiError) Error() string {
return fmt.Sprintf("CPI '%s' method responded with error: %s", e.method, e.cmdError)
}
func (e cpiError) Method() string {
return e.method
}
func (e cpiError) Type() string {
return e.cmdError.Type
}
func (e cpiError) Message() string {
return e.cmdError.Message
}
func (e cpiError) OkToRetry() bool {
return e.cmdError.OkToRetry
}