Files
troubleshoot/pkg/types/types.go
Evans Mungai 0113624352 chore(support-bundle): respect using load-cluster-specs=false (#1634)
* fix: Allow using load-cluster-specs=false

Signed-off-by: Evans Mungai <evans@replicated.com>

* Some more simplification

Signed-off-by: Evans Mungai <evans@replicated.com>

* Ensure error in loading specs is printed in CLI

Signed-off-by: Evans Mungai <evans@replicated.com>

* Run linter

Signed-off-by: Evans Mungai <evans@replicated.com>

* Fix failing tests

Signed-off-by: Evans Mungai <evans@replicated.com>

* Remove unnecessary test case rename

Signed-off-by: Evans Mungai <evans@replicated.com>

* Fix error wrapping

Signed-off-by: Evans Mungai <evans@replicated.com>

* Check if load-cluster-specs was provided in cli

Signed-off-by: Evans Mungai <evans@replicated.com>

* Better wording in comments

Signed-off-by: Evans Mungai <evans@replicated.com>

---------

Signed-off-by: Evans Mungai <evans@replicated.com>
2024-10-11 13:48:32 -04:00

57 lines
897 B
Go

package types
import (
"fmt"
)
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
Err error
}
type ExitCodeWarning struct {
Msg string
}
func (e *ExitCodeError) Error() string {
return e.Msg
}
func (e *ExitCodeError) Unwrap() error {
return e.Err
}
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, Err: theErr}
}
func NewExitCodeWarning(theErrMsg string) *ExitCodeWarning {
return &ExitCodeWarning{Msg: theErrMsg}
}
func (e *ExitCodeWarning) Warning() string {
return fmt.Sprintf("Warning: %s", e.Msg)
}