Documentation
¶
Overview ¶
Package errors provides unified error types for RADIUS authentication and accounting. It follows Go's error handling philosophy with typed errors for metrics and logging.
Index ¶
- func IsAcctError(err error) bool
- func IsAuthError(err error) bool
- func JoinErrors(errs ...error) error
- func NewAcctDropError(message string) error
- func NewAcctError(metricsType string, message string) error
- func NewAcctErrorWithCause(metricsType, message string, cause error) error
- func NewAcctErrorWithStage(metricsType, message, stage string) error
- func NewAcctNasNotFoundError(ip, identifier string) error
- func NewAcctUsernameEmptyError() error
- func NewAuthError(metricsType string, message string) error
- func NewAuthErrorWithCause(metricsType, message string, cause error) error
- func NewAuthErrorWithStage(metricsType, message, stage string) error
- func NewError(message string) error
- func NewMacBindError() error
- func NewOnlineLimitError(message string) error
- func NewPasswordMismatchError() error
- func NewUnauthorizedNasError(ip, identifier string, err error) error
- func NewUserDisabledError() error
- func NewUserExpiredError() error
- func NewUserNotExistsError() error
- func NewUsernameEmptyError() error
- func NewVlanBindError() error
- func WrapAcctError(metricsType string, err error) error
- func WrapAuthError(metricsType string, err error) error
- func WrapError(metricsType string, err error) error
- type AcctError
- type AuthError
- type AuthResult
- type RadiusError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsAcctError ¶
IsAcctError checks whether the error is an accounting error
func IsAuthError ¶
IsAuthError checks whether the error is an authentication error
func JoinErrors ¶
JoinErrors combines multiple errors into a single error. Useful for collecting errors from multiple guards.
func NewAcctDropError ¶
NewAcctDropError creates an accounting drop error
func NewAcctError ¶
NewAcctError creates an accounting error. Parameters:
- metricsType: The metrics key for monitoring (e.g., app.MetricsRadiusAcctDrop)
- message: Human-readable error message
func NewAcctErrorWithCause ¶
NewAcctErrorWithCause creates an accounting error wrapping an underlying cause.
func NewAcctErrorWithStage ¶
NewAcctErrorWithStage creates an accounting error with stage information.
func NewAcctNasNotFoundError ¶
NewAcctNasNotFoundError creates an error when NAS is not found for accounting
func NewAcctUsernameEmptyError ¶
func NewAcctUsernameEmptyError() error
NewAcctUsernameEmptyError creates an error for empty username in accounting
func NewAuthError ¶
NewAuthError creates an authentication error. Parameters:
- metricsType: The metrics key for monitoring (e.g., app.MetricsRadiusRejectNotExists)
- message: Human-readable error message
func NewAuthErrorWithCause ¶
NewAuthErrorWithCause creates an authentication error wrapping an underlying cause.
func NewAuthErrorWithStage ¶
NewAuthErrorWithStage creates an authentication error with stage information. This is useful for tracking where in the pipeline an error occurred.
func NewMacBindError ¶
func NewMacBindError() error
NewMacBindError creates an error for MAC address binding failures
func NewOnlineLimitError ¶
NewOnlineLimitError creates an error when online session limit is exceeded
func NewPasswordMismatchError ¶
func NewPasswordMismatchError() error
NewPasswordMismatchError creates an error for password validation failures
func NewUnauthorizedNasError ¶
NewUnauthorizedNasError creates an error for unauthorized NAS access
func NewUserDisabledError ¶
func NewUserDisabledError() error
NewUserDisabledError creates an error for disabled user accounts
func NewUserExpiredError ¶
func NewUserExpiredError() error
NewUserExpiredError creates an error for expired user accounts
func NewUserNotExistsError ¶
func NewUserNotExistsError() error
NewUserNotExistsError creates an error for non-existent users
func NewUsernameEmptyError ¶
func NewUsernameEmptyError() error
NewUsernameEmptyError creates an error for empty username
func NewVlanBindError ¶
func NewVlanBindError() error
NewVlanBindError creates an error for VLAN binding failures
func WrapAcctError ¶
WrapAcctError converts a general error into an AcctError If the error is already an AcctError, it returns it unchanged
func WrapAuthError ¶
WrapAuthError converts a general error into an AuthError If the error is already an AuthError, it returns it unchanged
Types ¶
type AcctError ¶
type AcctError struct {
MetricsType string // Metrics key for Prometheus/monitoring
Message string // Human-readable error message
ErrorStage string // Processing stage where error occurred (optional)
Cause error // Underlying error (optional)
}
AcctError represents a RADIUS accounting error with metrics support. Use this type for all accounting-related errors.
func GetAcctError ¶
GetAcctError retrieves accounting error details using errors.As
func (*AcctError) MetricsKey ¶
MetricsKey implements RadiusError interface
type AuthError ¶
type AuthError struct {
MetricsType string // Metrics key for Prometheus/monitoring
Message string // Human-readable error message
ErrorStage string // Pipeline stage where error occurred (optional)
Cause error // Underlying error (optional)
}
AuthError represents a RADIUS authentication error with metrics support. Use this type for all authentication-related errors to ensure consistent error handling and metrics reporting.
func GetAuthError ¶
GetAuthError retrieves authentication error details using errors.As
func (*AuthError) MetricsKey ¶
MetricsKey implements RadiusError interface
type AuthResult ¶
type AuthResult struct {
Success bool // Whether the stage completed successfully
Err error // Error if Success is false
ShouldStop bool // Whether pipeline execution should stop (success or handled error)
Response interface{} // Optional response data to pass to next stage
MetricsType string // Metrics key for tracking
}
AuthResult represents the outcome of an authentication pipeline stage. It provides a structured way to communicate results without using panic.
func NewAuthErrorResult ¶
func NewAuthErrorResult(err error) *AuthResult
NewAuthErrorResult creates a failed result from an error
func NewAuthResultWithStop ¶
func NewAuthResultWithStop() *AuthResult
NewAuthResultWithStop creates a successful result that stops the pipeline
type RadiusError ¶
type RadiusError interface {
error
// MetricsKey returns the metrics key for this error type
MetricsKey() string
// Stage returns the processing stage where the error occurred
Stage() string
}
RadiusError is the base interface for all RADIUS-related errors. It provides methods for metrics tracking and error categorization.
func GetRadiusError ¶
func GetRadiusError(err error) (RadiusError, bool)
GetRadiusError retrieves any RadiusError (AuthError or AcctError)