Documentation
¶
Overview ¶
Package errors provides the sentinel and typed errors used throughout the tacacs library, together with thin wrappers around the standard library error helpers (New, Is, As, Unwrap, Join) so that callers can import a single errors package.
Sentinel errors such as ErrSecretMismatch and ErrInvalidPacket describe well-known failure conditions. ValidationError wraps a sentinel with field-level context to aid packet diagnostics. All typed errors implement Unwrap so they participate in errors.Is / errors.As chains.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrSecretMismatch = stderrors.New("tacacs: shared secret mismatch") ErrInvalidPacket = stderrors.New("tacacs: invalid packet") ErrInvalidHeader = stderrors.New("tacacs: invalid header") ErrInvalidLength = stderrors.New("tacacs: invalid length") ErrInvalidArgument = stderrors.New("tacacs: invalid argument") ErrTooManyArguments = stderrors.New("tacacs: too many arguments") ErrInvalidSeqNo = stderrors.New("tacacs: invalid sequence number") ErrUnsupportedVersion = stderrors.New("tacacs: unsupported version") ErrUnsupportedType = stderrors.New("tacacs: unsupported packet type") ErrSessionClosed = stderrors.New("tacacs: session closed") ErrSessionAborted = stderrors.New("tacacs: session aborted") ErrFlagMismatch = stderrors.New("tacacs: flag mismatch") ErrNoServerConfigured = stderrors.New("tacacs: no server configured") ErrUnencryptedDisabled = stderrors.New("tacacs: unencrypted flag rejected") ErrNotImplemented = stderrors.New("tacacs: not implemented") )
Sentinel errors describing well-known failure conditions. They are compared with errors.Is so that wrapped (e.g. ValidationError) instances still match.
Functions ¶
Types ¶
type ValidationError ¶
ValidationError describes a packet or field validation failure with enough context to locate the problem. The optional Err field carries an underlying sentinel so that errors.Is can match it.
func NewValidationError ¶
func NewValidationError(field, reason string, err error) *ValidationError
NewValidationError constructs a ValidationError. Any of field, reason or err may be the zero value; the resulting message degrades gracefully.
func (*ValidationError) Error ¶
func (e *ValidationError) Error() string
Error implements the error interface. It joins the field, reason and underlying error (if any) under the "tacacs" prefix, trimming a duplicate "tacacs: " prefix from a wrapped sentinel so the prefix is not repeated.
func (*ValidationError) Unwrap ¶
func (e *ValidationError) Unwrap() error
Unwrap returns the underlying error so that errors.Is and errors.As traverse the wrapped sentinel.