9 type NotFoundError struct {
11 LastRequest interface{}
12 LastResponse interface{}
17 func (e *NotFoundError) Error() string {
23 return fmt.Sprintf("couldn't find resource (%d retries)", e.Retries)
26 return "couldn't find resource"
29 // UnexpectedStateError is returned when Refresh returns a state that's neither in Target nor Pending
30 type UnexpectedStateError struct {
33 ExpectedState []string
36 func (e *UnexpectedStateError) Error() string {
38 "unexpected state '%s', wanted target '%s'. last error: %s",
40 strings.Join(e.ExpectedState, ", "),
45 // TimeoutError is returned when WaitForState times out
46 type TimeoutError struct {
50 ExpectedState []string
53 func (e *TimeoutError) Error() string {
54 expectedState := "resource to be gone"
55 if len(e.ExpectedState) > 0 {
56 expectedState = fmt.Sprintf("state to become '%s'", strings.Join(e.ExpectedState, ", "))
59 extraInfo := make([]string, 0)
60 if e.LastState != "" {
61 extraInfo = append(extraInfo, fmt.Sprintf("last state: '%s'", e.LastState))
64 extraInfo = append(extraInfo, fmt.Sprintf("timeout: %s", e.Timeout.String()))
68 if len(extraInfo) > 0 {
69 suffix = fmt.Sprintf(" (%s)", strings.Join(extraInfo, ", "))
72 if e.LastError != nil {
73 return fmt.Sprintf("timeout while waiting for %s%s: %s",
74 expectedState, suffix, e.LastError)
77 return fmt.Sprintf("timeout while waiting for %s%s",
78 expectedState, suffix)