Documentation
¶
Overview ¶
Package errors provides comprehensive error handling for the auth module. It defines error types and provides context-aware error handling.
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 ¶
View Source
var ( // ErrInvalidToken is returned when a token is invalid ErrInvalidToken = errors.New("invalid token") // ErrExpiredToken is returned when a token has expired ErrExpiredToken = errors.New("token expired") // ErrMissingToken is returned when a token is missing ErrMissingToken = errors.New("token missing") // ErrInvalidSignature is returned when a token has an invalid signature ErrInvalidSignature = errors.New("invalid token signature") // ErrInvalidClaims is returned when a token has invalid claims ErrInvalidClaims = errors.New("invalid token claims") ErrUnauthorized = errors.New("unauthorized") // ErrForbidden is returned when a user is forbidden from performing an operation ErrForbidden = errors.New("forbidden") // ErrInvalidConfig is returned when the configuration is invalid ErrInvalidConfig = errors.New("invalid configuration") // ErrInternal is returned when an internal error occurs ErrInternal = errors.New("internal error") // ErrNotImplemented is returned when a feature is not implemented ErrNotImplemented = errors.New("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
func NewAuthError ¶
NewAuthError creates a new AuthError
Click to show internal directories.
Click to hide internal directories.