Documentation
¶
Overview ¶
Package errors provides unified error definitions for API layer.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrInvalidConfig is returned when config is nil or invalid. ErrInvalidConfig = errors.New("invalid config") // ErrInvalidArgument is returned when an argument is invalid. ErrInvalidArgument = errors.New("invalid argument") // ErrNotFound is returned when a resource is not found. ErrNotFound = errors.New("resource not found") // ErrAlreadyExists is returned when a resource already exists. ErrAlreadyExists = errors.New("resource already exists") // ErrAccessDenied is returned when access to a resource is denied. ErrAccessDenied = errors.New("access denied") // ErrTimeout is returned when an operation times out. ErrTimeout = errors.New("operation timeout") // ErrInternal is returned for internal server errors. ErrInternal = errors.New("internal server error") // ErrNotImplemented is returned when a feature is not implemented. ErrNotImplemented = errors.New("feature not implemented") )
Functions ¶
Types ¶
type AppError ¶
type AppError struct {
// Code is the error code.
Code string
// Message is the error message.
Message string
// Err is the underlying error.
Err error
// Context is additional context.
Context map[string]interface{}
}
AppError represents an application error with additional context.
func NewAppError ¶
NewAppError creates a new application error. Args: code - error code. message - error message. err - underlying error. Returns new application error.
func (*AppError) WithContext ¶
WithContext adds context to the error. Args: key - context key. value - context value. Returns the error for chaining.
Click to show internal directories.
Click to hide internal directories.