github.com/rjeczalik/terraform@v0.6.7-0.20160812060014-e251d5c7bd39/helper/resource/error.go (about) 1 package resource 2 3 import ( 4 "fmt" 5 "strings" 6 ) 7 8 type NotFoundError struct { 9 LastError error 10 LastRequest interface{} 11 LastResponse interface{} 12 Message string 13 Retries int 14 } 15 16 func (e *NotFoundError) Error() string { 17 if e.Message != "" { 18 return e.Message 19 } 20 21 return "couldn't find resource" 22 } 23 24 // UnexpectedStateError is returned when Refresh returns a state that's neither in Target nor Pending 25 type UnexpectedStateError struct { 26 LastError error 27 State string 28 ExpectedState []string 29 } 30 31 func (e *UnexpectedStateError) Error() string { 32 return fmt.Sprintf( 33 "unexpected state '%s', wanted target '%s'. last error: %s", 34 e.State, 35 strings.Join(e.ExpectedState, ", "), 36 e.LastError, 37 ) 38 } 39 40 // TimeoutError is returned when WaitForState times out 41 type TimeoutError struct { 42 LastError error 43 ExpectedState []string 44 } 45 46 func (e *TimeoutError) Error() string { 47 return fmt.Sprintf( 48 "timeout while waiting for state to become '%s'. last error: %s", 49 strings.Join(e.ExpectedState, ", "), 50 e.LastError, 51 ) 52 }