errors

package
v0.0.0-...-ad4d314 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2026 License: MIT Imports: 12 Imported by: 6

Documentation

Overview

Package errors defines the public typed error categories, wrappers, and inspection helpers used throughout mischcore.

The package provides:

  • stable category sentinels such as not found, conflict, partial failure, cancelled, not supported, and irreversible
  • OperationError wrappers that retain operation name plus path context
  • batch-error support that preserves errors.Is / errors.As behavior for aggregated per-item failures
  • helper predicates and accessors so callers do not need to parse error strings or reach into internal implementations
  • privilege classification helpers that let callers distinguish local permission failures that may be retryable through an admin handoff from remote or unsupported-backend failures

CLI and GUI consumers should prefer these helpers when branching on failure behavior instead of matching concrete backend errors directly.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound        = stderrors.New("not found")
	ErrAlreadyExists   = stderrors.New("already exists")
	ErrPermission      = stderrors.New("permission denied")
	ErrAdminRequired   = stderrors.New("admin privileges required")
	ErrInvalidPath     = stderrors.New("invalid path")
	ErrCancelled       = stderrors.New("cancelled")
	ErrNotSupported    = stderrors.New("not supported")
	ErrConflict        = stderrors.New("conflict")
	ErrIO              = stderrors.New("io failure")
	ErrPartial         = stderrors.New("partial failure")
	ErrReadOnly        = stderrors.New("read-only filesystem")
	ErrNoSpace         = stderrors.New("no space left on device")
	ErrNotDirectory    = stderrors.New("not a directory")
	ErrIsDirectory     = stderrors.New("is a directory")
	ErrNameTooLong     = stderrors.New("file name too long")
	ErrTooManySymlinks = stderrors.New("too many symbolic links")
	ErrCrossDevice     = stderrors.New("cross-device operation")
	ErrBusy            = stderrors.New("resource busy")
	ErrResourceLimit   = stderrors.New("resource limit exceeded")
	// ErrMutationUncertain marks a possible or partial mutation whose complete
	// effect cannot be reliably reconstructed. It does not establish an Undo
	// target. Join it with the underlying causes (and ErrPartial when applicable).
	// Existence/conflict helpers must not treat child causes as definitive root
	// outcomes; errors.Is still exposes those causes for diagnostics.
	ErrMutationUncertain = stderrors.New("mutation outcome uncertain")
	// ErrIrreversible marks an operation as no longer undoable/redoable because
	// the external world has changed (e.g. paths removed or replaced by other
	// processes). Consumers may prune such entries from undo/redo history.
	ErrIrreversible = stderrors.New("irreversible")
)

Functions

func DiagnosticMessage

func DiagnosticMessage(err error) string

DiagnosticMessage describes known causes without exposing dependency messages or paths that may contain credentials. It bounds traversal of batch failures.

func IsAdminRequired

func IsAdminRequired(err error) bool

func IsAlreadyExists

func IsAlreadyExists(err error) bool

IsAlreadyExists classifies a definitive rejected creation. An uncertain mutation may contain an existing child without establishing that outcome.

func IsBusy

func IsBusy(err error) bool

func IsCancelled

func IsCancelled(err error) bool

func IsConflict

func IsConflict(err error) bool

IsConflict excludes uncertain mutations so a child conflict cannot authorize a retry or be mistaken for a rejected root operation.

func IsCrossDevice

func IsCrossDevice(err error) bool

func IsDirectory

func IsDirectory(err error) bool

func IsIO

func IsIO(err error) bool

func IsInvalidPath

func IsInvalidPath(err error) bool

func IsIrreversible

func IsIrreversible(err error) bool

func IsNameTooLong

func IsNameTooLong(err error) bool

func IsNoSpace

func IsNoSpace(err error) bool

func IsNotDirectory

func IsNotDirectory(err error) bool

func IsNotFound

func IsNotFound(err error) bool

IsNotFound classifies a definitive absence, not a child failure within a mutation whose overall effect is uncertain.

func IsNotSupported

func IsNotSupported(err error) bool

func IsPartial

func IsPartial(err error) bool

func IsPermission

func IsPermission(err error) bool

func IsReadOnly

func IsReadOnly(err error) bool

func IsResourceLimit

func IsResourceLimit(err error) bool
func IsTooManySymlinks(err error) bool

func Kind

func Kind(err error) string

Kind returns a stable, UI-safe category for a known mischcore error.

func NeedsLocalAdmin

func NeedsLocalAdmin(err error, backend BackendKind) bool

func NewBatch

func NewBatch(errs ...error) error

func Operation

func Operation(err error) string

func Path

func Path(err error) string

func SourcePath

func SourcePath(err error) string

func TargetPath

func TargetPath(err error) string

func Wrap

func Wrap(op, path string, err error) error

func WrapPaths

func WrapPaths(op, sourcePath, targetPath string, err error) error

Types

type BackendKind

type BackendKind string
const (
	BackendUnknown BackendKind = ""
	BackendLocal   BackendKind = "local"
	BackendRemote  BackendKind = "remote"
	BackendDevice  BackendKind = "device"
)

type BatchError

type BatchError struct {
	// contains filtered or unexported fields
}

func (*BatchError) Error

func (e *BatchError) Error() string

func (*BatchError) Errors

func (e *BatchError) Errors() []error

func (*BatchError) Unwrap

func (e *BatchError) Unwrap() []error

type MutationNotStartedError

type MutationNotStartedError struct{ Err error }

MutationNotStartedError records a provider-confirmed failure before any mutation request was sent. It preserves the transport cause without claiming that an unacknowledged mutation may have committed. Providers must not use this marker once a request that can change storage has been issued.

func (*MutationNotStartedError) Error

func (e *MutationNotStartedError) Error() string

func (*MutationNotStartedError) Unwrap

func (e *MutationNotStartedError) Unwrap() error

type MutationOutcomeError

type MutationOutcomeError struct {
	MutationErr    error
	ObservationErr error
}

MutationOutcomeError separates the mutation reply from failed recovery observation. Both causes remain available through errors.Is/errors.As. A nil MutationErr means the write reported success but its complete effect could not be confirmed. Observation cancellation/deadline is not execution cancellation; engine lifecycle classification must use MutationErr.

func (*MutationOutcomeError) Error

func (e *MutationOutcomeError) Error() string

func (*MutationOutcomeError) Unwrap

func (e *MutationOutcomeError) Unwrap() []error

type OperationError

type OperationError struct {
	Op         string
	Path       string
	SourcePath string
	TargetPath string
	Err        error
}

func (*OperationError) Error

func (e *OperationError) Error() string

func (*OperationError) Unwrap

func (e *OperationError) Unwrap() error

type PrivilegeAction

type PrivilegeAction string
const (
	PrivilegeActionNone       PrivilegeAction = ""
	PrivilegeActionLocalAdmin PrivilegeAction = "local_admin"
)

type PrivilegeRequirement

type PrivilegeRequirement struct {
	Required   bool
	Action     PrivilegeAction
	Backend    BackendKind
	Operation  string
	Path       string
	SourcePath string
	TargetPath string
	Reason     string
}

func ClassifyPrivilegeRequirement

func ClassifyPrivilegeRequirement(err error, backend BackendKind) PrivilegeRequirement

Jump to

Keyboard shortcuts

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