Documentation
¶
Overview ¶
Package errors provides custom error types for the sync package
Index ¶
- func Component(component string) componentArg
- func IsRetryable(err error) bool
- type ErrorCode
- type Kind
- type Operation
- type SyncError
- func E(args ...interface{}) *SyncError
- func New(op Operation, err error) *SyncError
- func NewConflictError(op Operation, cause error) *SyncError
- func NewNetworkError(op Operation, cause error) *SyncError
- func NewRetryable(op Operation, err error) *SyncError
- func NewStorageError(op Operation, cause error) *SyncError
- func NewValidationError(op Operation, cause error) *SyncError
- func NewWithComponent(op Operation, component string, err error) *SyncError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Component ¶ added in v0.9.0
func Component(component string) componentArg
Component creates a component string argument for E() that's clearly distinguished from context messages
func IsRetryable ¶
IsRetryable checks if an error is a retryable SyncError
Types ¶
type Kind ¶ added in v0.9.0
type Kind string
Kind represents the category of error for structured error handling
const ( KindInvalid Kind = "INVALID" // Invalid input or request KindNotFound Kind = "NOT_FOUND" // Resource not found KindPermission Kind = "PERMISSION" // Permission denied KindInternal Kind = "INTERNAL" // Internal server error KindTimeout Kind = "TIMEOUT" // Operation timeout KindConflict Kind = "CONFLICT" // Resource conflict KindTooLarge Kind = "TOO_LARGE" // Request too large KindMethodNotAllowed Kind = "METHOD_NOT_ALLOWED" // HTTP method not allowed )
type SyncError ¶
type SyncError struct {
// Operation during which the error occurred
Op Operation
// Component that generated the error (e.g., "store", "transport")
Component string
// Underlying error
Err error
// Whether the operation can be retried
Retryable bool
// Error code for the error type
Code ErrorCode
// Kind represents the category of error
Kind Kind
// Metadata for additional context
Metadata map[string]interface{}
}
SyncError represents an error that occurred during synchronization
func E ¶ added in v0.9.0
func E(args ...interface{}) *SyncError
E creates a structured error using a builder pattern. This function provides a flexible way to create errors with multiple attributes. Arguments can be provided in any order and include:
- Operation: specifies the operation during which the error occurred
- Component: specifies the component that generated the error (string)
- Kind: specifies the category of error
- error: the underlying error
- string: additional context message
Example:
err := E(Op("httptransport.handlePush"), Component("httptransport"), Kind(KindInvalid), underlyingErr, "decode request")
func NewConflictError ¶
NewConflictError creates a new conflict-related SyncError
func NewNetworkError ¶
NewNetworkError creates a new network-related SyncError
func NewRetryable ¶
NewRetryable creates a new retryable SyncError
func NewStorageError ¶
NewStorageError creates a new storage-related SyncError
func NewValidationError ¶
NewValidationError creates a new validation-related SyncError
func NewWithComponent ¶
NewWithComponent creates a new SyncError with component information