errors

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: May 30, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsQvmError

func IsQvmError(err error) bool

IsQvmError reports whether err or any error in its chain is a *QvmError.

func SuggestClose

func SuggestClose(query string, candidates []string, maxResults int) []string

SuggestClose returns fuzzy-matched close alternatives to query from candidates. Returns up to maxResults results.

Types

type Code

type Code string

Code identifies the category of a qvm error.

const (
	CodeUnknownVersion   Code = "UNKNOWN_VERSION"
	CodeUnknownArch      Code = "UNKNOWN_ARCH"
	CodeUnknownModule    Code = "UNKNOWN_MODULE"
	CodeNetworkError     Code = "NETWORK_ERROR"
	CodeExtractError     Code = "EXTRACT_ERROR"
	CodeChecksumError    Code = "CHECKSUM_ERROR"
	CodeNotInstalled     Code = "NOT_INSTALLED"
	CodeAlreadyInstalled Code = "ALREADY_INSTALLED"
	CodeNoModules        Code = "NO_MODULES"
	CodeConfigError      Code = "CONFIG_ERROR"
	CodeIOError          Code = "IO_ERROR"
)

type QvmError

type QvmError struct {
	Code        Code
	Message     string
	Suggestions []string
	Cause       error
}

QvmError is the structured error type for qvm.

func New

func New(code Code, message string) *QvmError

New creates a QvmError with the given code and message.

func Newf

func Newf(code Code, format string, args ...any) *QvmError

Newf creates a QvmError with a formatted message.

func SuggestArch

func SuggestArch(bad string, available []string) *QvmError

SuggestArch produces suggestions when an arch string is unknown.

func SuggestModule

func SuggestModule(bad string, available []string) *QvmError

SuggestModule produces suggestions when a module name is unknown.

func SuggestVersion

func SuggestVersion(bad string, available []string) *QvmError

SuggestVersion produces suggestions when a version string is unknown.

func Wrap

func Wrap(code Code, cause error, message string) *QvmError

Wrap wraps a cause error.

func (*QvmError) Error

func (e *QvmError) Error() string

Error implements the error interface, including suggestions if present.

func (*QvmError) Unwrap

func (e *QvmError) Unwrap() error

Unwrap returns the cause of the error, if any.

func (*QvmError) WithSuggestions

func (e *QvmError) WithSuggestions(suggestions ...string) *QvmError

WithSuggestions returns a copy of the error with additional suggestions.

Jump to

Keyboard shortcuts

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