errors

package
v0.7.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 8, 2025 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package errors provides custom error types for the sync package

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsRetryable

func IsRetryable(err error) bool

IsRetryable checks if an error is a retryable SyncError

Types

type ErrorCode

type ErrorCode string

ErrorCode represents the type of error that occurred

const (
	ErrCodeNetworkFailure    ErrorCode = "NETWORK_FAILURE"
	ErrCodeStorageFailure    ErrorCode = "STORAGE_FAILURE"
	ErrCodeConflictFailure   ErrorCode = "CONFLICT_FAILURE"
	ErrCodeValidationFailure ErrorCode = "VALIDATION_FAILURE"
)

type Operation

type Operation string

Operation represents the type of sync operation

const (
	OpSync            Operation = "sync"
	OpPush            Operation = "push"
	OpPull            Operation = "pull"
	OpStore           Operation = "store"
	OpLoad            Operation = "load"
	OpConflictResolve Operation = "conflict_resolve"
	OpTransport       Operation = "transport"
	OpClose           Operation = "close"
)

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

	// Metadata for additional context
	Metadata map[string]interface{}
}

SyncError represents an error that occurred during synchronization

func New

func New(op Operation, err error) *SyncError

New creates a new SyncError

func NewConflictError

func NewConflictError(op Operation, cause error) *SyncError

NewConflictError creates a new conflict-related SyncError

func NewNetworkError

func NewNetworkError(op Operation, cause error) *SyncError

NewNetworkError creates a new network-related SyncError

func NewRetryable

func NewRetryable(op Operation, err error) *SyncError

NewRetryable creates a new retryable SyncError

func NewStorageError

func NewStorageError(op Operation, cause error) *SyncError

NewStorageError creates a new storage-related SyncError

func NewValidationError

func NewValidationError(op Operation, cause error) *SyncError

NewValidationError creates a new validation-related SyncError

func NewWithComponent

func NewWithComponent(op Operation, component string, err error) *SyncError

NewWithComponent creates a new SyncError with component information

func (*SyncError) Error

func (e *SyncError) Error() string

func (*SyncError) Unwrap

func (e *SyncError) Unwrap() error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL