andrey
2 years ago
4 changed files with 55 additions and 29 deletions
@ -0,0 +1,31 @@ |
|||
package console |
|||
|
|||
import ( |
|||
"errors" |
|||
"fmt" |
|||
"strings" |
|||
) |
|||
|
|||
var ( |
|||
ErrNotFound = errors.New("command not found") |
|||
ErrCommandNil = errors.New("console: Register command is nil") |
|||
ErrExecuteNil = errors.New("console: execute is nil") |
|||
ErrCommandDuplicate = errors.New("console: duplicate command") |
|||
) |
|||
|
|||
type AlternativesError struct { |
|||
Alt []string |
|||
Err error |
|||
} |
|||
|
|||
func (e AlternativesError) Error() string { |
|||
return fmt.Sprintf("%s, alternatives: [%s]", e.Err, strings.Join(e.Alt, ",")) |
|||
} |
|||
|
|||
func (e AlternativesError) Is(err error) bool { |
|||
return errors.Is(e.Err, err) |
|||
} |
|||
|
|||
func (e AlternativesError) Unwrap() error { |
|||
return e.Err |
|||
} |
Loading…
Reference in new issue