package cmdutil import "errors" // SilentError is an error that should not be printed to stderr. // The command's exit code will still be non-zero. type SilentError struct { Err error } func (e *SilentError) Error() string { return e.Err.Error() } func (e *SilentError) Silent() bool { return true } func (e *SilentError) Unwrap() error { return e.Err } // CancelError indicates the user cancelled an operation. type CancelError struct{} func (e *CancelError) Error() string { return "operation cancelled" } // AuthError indicates an authentication failure. type AuthError struct { Err error } func (e *AuthError) Error() string { if e.Err != nil { return e.Err.Error() } return "authentication required: run 'tng auth login'" } func (e *AuthError) Unwrap() error { return e.Err } func IsAuthError(err error) bool { var ae *AuthError return errors.As(err, &ae) } func IsCancelError(err error) bool { var ce *CancelError return errors.As(err, &ce) }