errors

package
v1.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 15, 2026 License: MIT Imports: 2 Imported by: 0

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

View Source
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

func As

func As(err error, target any) bool

func Is

func Is(err, target error) bool

func Join

func Join(errs ...error) error

func New

func New(text string) error

New, Is, As, Unwrap and Join wrap the standard library error helpers so that callers of the tacacs library can import a single errors package instead of aliasing the standard one.

func Unwrap

func Unwrap(err error) error

Types

type ValidationError

type ValidationError struct {
	Field  string
	Reason string
	Err    error
}

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL