Files
troubleshoot/pkg/types/types.go
Nathan Sullivan 3548b46cfc support multiple exit codes based on what went wrong/right (#1135)
0 = all passed, 3 = at least one failure, 4 = no failures but at least 1 warn

1 as a catch all (generic errors), 2 for invalid input/specs etc

ref https://github.com/replicatedhq/troubleshoot/issues/1131

docs https://github.com/replicatedhq/troubleshoot.sh/pull/489
2023-05-10 09:33:13 +10:00

36 lines
555 B
Go

package types
type NotFoundError struct {
Name string
}
func (e *NotFoundError) Error() string {
return e.Name + ": not found"
}
type ExitError interface {
Error() string
ExitStatus() int
}
type ExitCodeError struct {
Msg string
Code int
}
func (e *ExitCodeError) Error() string {
return e.Msg
}
func (e *ExitCodeError) ExitStatus() int {
return e.Code
}
func NewExitCodeError(exitCode int, theErr error) *ExitCodeError {
useErr := ""
if theErr != nil {
useErr = theErr.Error()
}
return &ExitCodeError{Msg: useErr, Code: exitCode}
}