Documentation
¶
Overview ¶
Package errors provides comprehensive error handling for the auth module. It defines error types and provides context-aware error handling.
IMPORTANT: This package is now implemented using the main errors framework while maintaining backward compatibility with existing code. New code should use the main errors framework directly instead of this package.
The main errors framework provides a more comprehensive error handling system with better integration with the hybrid architecture. It includes error types for different layers (domain, application, infrastructure) and better support for error context, HTTP status mapping, and error recovery.
Index ¶
- Variables
- func GetContext(err error, key string) (interface{}, bool)
- func GetMessage(err error) (string, bool)
- func GetOp(err error) (string, bool)
- func WithContext(err error, key string, value interface{}) error
- func WithMessage(err error, message string) error
- func WithOp(err error, op string) error
- func Wrap(err error, message string) error
- type AuthError
Constants ¶
This section is empty.
Variables ¶
var ( // ErrInvalidToken is returned when a token is invalid ErrInvalidToken = errors.NewAuthenticationError("invalid token", "", nil) // ErrExpiredToken is returned when a token has expired ErrExpiredToken = errors.NewAuthenticationError("token expired", "", nil) // ErrMissingToken is returned when a token is missing ErrMissingToken = errors.NewAuthenticationError("token missing", "", nil) // ErrInvalidSignature is returned when a token has an invalid signature ErrInvalidSignature = errors.NewAuthenticationError("invalid token signature", "", nil) // ErrInvalidClaims is returned when a token has invalid claims ErrInvalidClaims = errors.NewAuthenticationError("invalid token claims", "", nil) ErrUnauthorized = errors.ErrUnauthorized // ErrForbidden is returned when a user is forbidden from performing an operation ErrForbidden = errors.ErrForbidden // ErrInvalidConfig is returned when the configuration is invalid ErrInvalidConfig = errors.NewConfigurationError("invalid configuration", "", "", nil) // ErrInternal is returned when an internal error occurs ErrInternal = errors.ErrInternal // ErrNotImplemented is returned when a feature is not implemented ErrNotImplemented = errors.New(errors.InternalErrorCode, "not implemented") )
Standard error types
Functions ¶
func GetContext ¶
GetContext gets a context value from an error
func GetMessage ¶
GetMessage gets the message from an error
func WithContext ¶
WithContext adds context to an error
func WithMessage ¶
WithMessage adds a message to an error
Types ¶
type AuthError ¶
type AuthError struct {
// Err is the underlying error
Err error
// Op is the operation that caused the error
Op string
// Message is a human-readable message
Message string
// Context contains additional context for the error
Context map[string]interface{}
}
AuthError represents an authentication or authorization error with context It's now a wrapper around the new errors framework's AuthenticationError
func NewAuthError ¶
NewAuthError creates a new AuthError