// vfs/vfserror/vfserror.go package vfserror import ( "errors" "fmt" ) // Common VFS errors var ( ErrNotFound = errors.New("vfs: key not found") ErrInvalidKey = errors.New("vfs: invalid key") ErrAlreadyExists = errors.New("vfs: key already exists") ErrCapacityExceeded = errors.New("vfs: capacity exceeded") ErrCorruptedFile = errors.New("vfs: corrupted file") ErrInvalidSize = errors.New("vfs: invalid size") ErrOperationTimeout = errors.New("vfs: operation timeout") ) // VFSError represents a VFS-specific error with context type VFSError struct { Op string // Operation that failed Key string // Key that caused the error Err error // Underlying error Size int64 // Size information if relevant } // Error implements the error interface func (e *VFSError) Error() string { if e.Key != "" { return fmt.Sprintf("vfs: %s failed for key %q: %v", e.Op, e.Key, e.Err) } return fmt.Sprintf("vfs: %s failed: %v", e.Op, e.Err) } // Unwrap returns the underlying error func (e *VFSError) Unwrap() error { return e.Err } // NewVFSError creates a new VFS error with context func NewVFSError(op, key string, err error) *VFSError { return &VFSError{ Op: op, Key: key, Err: err, } } // NewVFSErrorWithSize creates a new VFS error with size context func NewVFSErrorWithSize(op, key string, size int64, err error) *VFSError { return &VFSError{ Op: op, Key: key, Size: size, Err: err, } }