34 lines
615 B
Go
34 lines
615 B
Go
package protocol
|
|
|
|
type CLIError struct {
|
|
Code string
|
|
ExitCode int
|
|
Message string
|
|
Err error
|
|
}
|
|
|
|
func (e *CLIError) Error() string {
|
|
return e.Message
|
|
}
|
|
|
|
func (e *CLIError) Unwrap() error {
|
|
return e.Err
|
|
}
|
|
|
|
func NewCLIError(code string, exitCode int, message string, err error) error {
|
|
return &CLIError{
|
|
Code: code,
|
|
ExitCode: exitCode,
|
|
Message: message,
|
|
Err: err,
|
|
}
|
|
}
|
|
|
|
func InvalidInput(message string, err error) error {
|
|
return NewCLIError("invalid_input", 30, message, err)
|
|
}
|
|
|
|
func NoMatchingWork(message string) error {
|
|
return NewCLIError("no_matching_work", 10, message, nil)
|
|
}
|