github.com/helmwave/helmwave@v0.36.4-0.20240509190856-b35563eba4c6/pkg/monitor/errors.go (about) 1 package monitor 2 3 import ( 4 "errors" 5 "fmt" 6 ) 7 8 var ( 9 ErrNameEmpty = errors.New("release name is empty") 10 11 ErrFailureStreak = errors.New("monitor triggered failure threshold") 12 13 ErrLowTotalTimeout = errors.New("total timeout is less than iteration timeout") 14 15 ErrLowInterval = errors.New("interval cannot be zero") 16 ) 17 18 type InitError struct { 19 Err error 20 } 21 22 func NewMonitorInitError(err error) error { 23 return &InitError{Err: err} 24 } 25 26 func (err InitError) Error() string { 27 return fmt.Sprintf("monitor failed to initialize: %s", err.Err) 28 } 29 30 func (err InitError) Unwrap() error { 31 return err.Err 32 } 33 34 type YAMLDecodeError struct { 35 Err error 36 } 37 38 func NewYAMLDecodeError(err error) error { 39 return &YAMLDecodeError{Err: err} 40 } 41 42 func (err YAMLDecodeError) Error() string { 43 return fmt.Sprintf("failed to decode lifecycle config from YAML: %s", err.Err) 44 } 45 46 func (err YAMLDecodeError) Unwrap() error { 47 return err.Err 48 } 49 50 type DuplicateError struct { 51 Name string 52 } 53 54 func NewDuplicateError(name string) error { 55 return &DuplicateError{Name: name} 56 } 57 58 func (err DuplicateError) Error() string { 59 return fmt.Sprint("monitor duplicate: ", err.Name) 60 } 61 62 type NotExistsError struct { 63 Name string 64 } 65 66 func NewNotExistsError(name string) error { 67 return &NotExistsError{Name: name} 68 } 69 70 func (err NotExistsError) Error() string { 71 return fmt.Sprintf("monitor doesn't exist: %s", err.Name) 72 } 73 74 type SubMonitorError struct { 75 Err error 76 } 77 78 func NewSubMonitorError(err error) error { 79 return &SubMonitorError{Err: err} 80 } 81 82 func (err SubMonitorError) Error() string { 83 return fmt.Sprintf("submonitor config error: %s", err.Err) 84 } 85 86 func (err SubMonitorError) Unwrap() error { 87 return err.Err 88 }