errors

package
v1.13.0 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsCorruption

func IsCorruption(err error) bool

IsCorruption checks if an error indicates data corruption

func IsNotFound

func IsNotFound(err error) bool

IsNotFound checks if an error is a not-found error

func IsRetryable

func IsRetryable(err error) bool

IsRetryable checks if an error is retryable

func IsStorageFull

func IsStorageFull(err error) bool

IsStorageFull checks if an error indicates storage is full

func IsTimeout

func IsTimeout(err error) bool

IsTimeout checks if an error is a timeout error

Types

type ErrorType

type ErrorType int

ErrorType represents the category of storage error

const (
	// TypeNotFound indicates the requested resource was not found
	TypeNotFound ErrorType = iota
	// TypeInvalidRequest indicates the request parameters were invalid
	TypeInvalidRequest
	// TypeStorageFull indicates storage capacity has been exceeded
	TypeStorageFull
	// TypeCorruption indicates data corruption was detected
	TypeCorruption
	// TypeTemporary indicates a transient error that may succeed on retry
	TypeTemporary
	// TypeIO indicates a file system I/O error
	TypeIO
	// TypeLock indicates a resource locking conflict
	TypeLock
	// TypeTimeout indicates an operation timed out
	TypeTimeout
	// TypeInternal indicates an unexpected internal error
	TypeInternal
)

func GetType

func GetType(err error) (ErrorType, bool)

GetType extracts the error type from an error

type StorageError

type StorageError struct {
	Type      ErrorType
	Op        string // Operation that failed (e.g., "Get", "Put", "Delete")
	Key       string // Key involved in the operation, if applicable
	Message   string // User-friendly error message
	Retryable bool   // Whether the operation can be retried
	// contains filtered or unexported fields
}

StorageError represents a high-level storage error that abstracts internal implementation details

func NewCorruptionError

func NewCorruptionError(op, key string, underlying error) *StorageError

NewCorruptionError creates a new corruption error

func NewIOError

func NewIOError(op, key string, underlying error) *StorageError

NewIOError creates a new I/O error

func NewIORetryableError

func NewIORetryableError(op, key string, underlying error) *StorageError

NewIORetryableError creates a new I/O error that is retryable

func NewInternalError

func NewInternalError(op string, underlying error) *StorageError

NewInternalError creates a new internal error for unexpected conditions

func NewInvalidRequestError

func NewInvalidRequestError(op, message string) *StorageError

NewInvalidRequestError creates a new invalid request error

func NewLockError

func NewLockError(op, key string, underlying error) *StorageError

NewLockError creates a new lock conflict error

func NewNotFoundError

func NewNotFoundError(op, key string) *StorageError

NewNotFoundError creates a new not-found error

func NewStorageFullError

func NewStorageFullError(op string, underlying error) *StorageError

NewStorageFullError creates a new storage full error

func NewTemporaryError

func NewTemporaryError(op, key string, underlying error) *StorageError

NewTemporaryError creates a new temporary error that can be retried

func NewTimeoutError

func NewTimeoutError(op, key string) *StorageError

NewTimeoutError creates a new timeout error

func (*StorageError) Error

func (e *StorageError) Error() string

Error implements the error interface

func (*StorageError) GetType

func (e *StorageError) GetType() ErrorType

GetType returns the error type

func (*StorageError) IsRetryable

func (e *StorageError) IsRetryable() bool

IsRetryable returns whether this error represents a retryable condition

func (*StorageError) Unwrap

func (e *StorageError) Unwrap() error

Unwrap returns the underlying error for internal debugging

type VersionMismatchError added in v1.12.0

type VersionMismatchError struct {
	Op             string
	Key            string
	CurrentVersion uint64
}

VersionMismatchError reports a lost conditional (CAS) operation: the key's current version did not equal the caller's expected version (issue #254). CurrentVersion carries the version observed after the operation resolved — 0 means the key is absent — so the caller can re-read, re-decide, and retry with a fresh precondition. It is deliberately not a StorageError: it is not retryable as-is (retrying with the same expectation loses again by definition) and represents a normal outcome, not a failure.

func IsVersionMismatch added in v1.12.0

func IsVersionMismatch(err error) (*VersionMismatchError, bool)

IsVersionMismatch reports whether err is (or wraps) a VersionMismatchError, returning it for access to CurrentVersion.

func NewVersionMismatchError added in v1.12.0

func NewVersionMismatchError(op, key string, current uint64) *VersionMismatchError

NewVersionMismatchError creates a VersionMismatchError.

func (*VersionMismatchError) Error added in v1.12.0

func (e *VersionMismatchError) Error() string

Jump to

Keyboard shortcuts

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