errors

package
v1.0.9 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CodeOk      int = iota // Used when the program exits without errors
	CodeUnknown            // Used when no other exit code is appropriate
)

General exit codes

View Source
const (
	CodeRitefileNotFound int = iota + 100
	CodeRitefileAlreadyExists
	CodeRitefileDecode
	CodeRitefileVersionCheckError
	CodeRitefileInvalid
	CodeRitefileCycle
	CodeRitefileDoesNotMatchChecksum
)

Ritefile related exit codes

View Source
const (
	CodeTaskNotFound int = iota + 200
	CodeTaskRunError
	CodeTaskInternal
	CodeTaskNameConflict
	CodeTaskCalledTooManyTimes
	CodeTaskCancelled
	CodeTaskMissingRequiredVars
	CodeTaskNotAllowedVars
)

Task related exit codes

View Source
const (
	CodeRitercNotFoundError int = iota + 50
)

Riterc related exit codes

Variables

This section is empty.

Functions

func As

func As(err error, target any) bool

As wraps the standard errors.As function so that we don't need to alias that package.

func Is

func Is(err, target error) bool

Is wraps the standard errors.Is function so that we don't need to alias that package.

func New

func New(text string) error

New returns an error that formats as the given text. Each call to New returns a distinct error value even if the text is identical. This wraps the standard errors.New function so that we don't need to alias that package.

func Unwrap

func Unwrap(err error) error

Unwrap wraps the standard errors.Unwrap function so that we don't need to alias that package.

Types

type IncludeEscapesTreeError added in v1.0.0

type IncludeEscapesTreeError struct {
	IncludePath string
	Reason      string
}

IncludeEscapesTreeError is returned when an `includes:` path is rejected because it would load a file from outside the sandbox: the union of the process working directory and the directory containing the root Ritefile. Includes are scoped this way so that malicious or accidental references (`/etc/passwd`, `../../../etc/hosts`, symlinks pointing outside the repo) can't cause arbitrary file reads or leak contents into error messages.

func (IncludeEscapesTreeError) Code added in v1.0.0

func (err IncludeEscapesTreeError) Code() int

func (IncludeEscapesTreeError) Error added in v1.0.0

func (err IncludeEscapesTreeError) Error() string

type MissingVar

type MissingVar struct {
	Name          string
	AllowedValues []string
}

func (MissingVar) String

func (v MissingVar) String() string

type NotAllowedVar

type NotAllowedVar struct {
	Value string
	Enum  []string
	Name  string
}

type RitefileAlreadyExistsError added in v1.0.0

type RitefileAlreadyExistsError struct{}

RitefileAlreadyExistsError is returned on creating a Ritefile if one already exists.

func (RitefileAlreadyExistsError) Code added in v1.0.0

func (err RitefileAlreadyExistsError) Code() int

func (RitefileAlreadyExistsError) Error added in v1.0.0

func (err RitefileAlreadyExistsError) Error() string

type RitefileCycleError added in v1.0.0

type RitefileCycleError struct {
	Source      string
	Destination string
}

RitefileCycleError is returned when we detect that a Ritefile includes a set of Ritefiles that include each other in a cycle.

func (RitefileCycleError) Code added in v1.0.0

func (err RitefileCycleError) Code() int

func (RitefileCycleError) Error added in v1.0.0

func (err RitefileCycleError) Error() string

type RitefileDecodeError added in v1.0.0

type RitefileDecodeError struct {
	Message  string
	Location string
	Line     int
	Column   int
	Tag      string
	Snippet  string
	Err      error
}

func NewRitefileDecodeError added in v1.0.0

func NewRitefileDecodeError(err error, node *yaml.Node) *RitefileDecodeError

func (*RitefileDecodeError) Code added in v1.0.0

func (err *RitefileDecodeError) Code() int

func (*RitefileDecodeError) Debug added in v1.0.0

func (err *RitefileDecodeError) Debug() string

func (*RitefileDecodeError) Error added in v1.0.0

func (err *RitefileDecodeError) Error() string

func (*RitefileDecodeError) Unwrap added in v1.0.0

func (err *RitefileDecodeError) Unwrap() error

func (*RitefileDecodeError) WithFileInfo added in v1.0.0

func (err *RitefileDecodeError) WithFileInfo(location string, snippet string) *RitefileDecodeError

func (*RitefileDecodeError) WithMessage added in v1.0.0

func (err *RitefileDecodeError) WithMessage(format string, a ...any) *RitefileDecodeError

func (*RitefileDecodeError) WithTypeMessage added in v1.0.0

func (err *RitefileDecodeError) WithTypeMessage(t string) *RitefileDecodeError

type RitefileDoesNotMatchChecksum added in v1.0.0

type RitefileDoesNotMatchChecksum struct {
	URI              string
	ExpectedChecksum string
	ActualChecksum   string
}

RitefileDoesNotMatchChecksum is returned when a Ritefile's checksum does not match the one pinned in the parent Ritefile.

func (*RitefileDoesNotMatchChecksum) Code added in v1.0.0

func (err *RitefileDoesNotMatchChecksum) Code() int

func (*RitefileDoesNotMatchChecksum) Error added in v1.0.0

func (err *RitefileDoesNotMatchChecksum) Error() string

type RitefileInvalidError added in v1.0.0

type RitefileInvalidError struct {
	URI string
	Err error
}

RitefileInvalidError is returned when the Ritefile contains syntax errors or cannot be parsed for some reason.

func (RitefileInvalidError) Code added in v1.0.0

func (err RitefileInvalidError) Code() int

func (RitefileInvalidError) Error added in v1.0.0

func (err RitefileInvalidError) Error() string

type RitefileNotFoundError added in v1.0.0

type RitefileNotFoundError struct {
	URI         string
	Walk        bool
	AskInit     bool
	OwnerChange bool
}

RitefileNotFoundError is returned when no appropriate Ritefile is found when searching the filesystem.

func (RitefileNotFoundError) Code added in v1.0.0

func (err RitefileNotFoundError) Code() int

func (RitefileNotFoundError) Error added in v1.0.0

func (err RitefileNotFoundError) Error() string

type RitefileVersionCheckError added in v1.0.0

type RitefileVersionCheckError struct {
	URI           string
	SchemaVersion *semver.Version
	Message       string
}

RitefileVersionCheckError is returned when the user attempts to run a Ritefile that does not contain a schema version key or if they try to use a feature that is not supported by the schema version.

func (*RitefileVersionCheckError) Code added in v1.0.0

func (err *RitefileVersionCheckError) Code() int

func (*RitefileVersionCheckError) Error added in v1.0.0

func (err *RitefileVersionCheckError) Error() string

type RitercNotFoundError added in v1.0.0

type RitercNotFoundError struct {
	URI  string
	Walk bool
}

func (RitercNotFoundError) Code added in v1.0.0

func (err RitercNotFoundError) Code() int

func (RitercNotFoundError) Error added in v1.0.0

func (err RitercNotFoundError) Error() string

type TaskCalledTooManyTimesError

type TaskCalledTooManyTimesError struct {
	TaskName        string
	MaximumTaskCall int
}

TaskCalledTooManyTimesError is returned when the maximum task call limit is exceeded. This is to prevent infinite loops and cyclic dependencies.

func (*TaskCalledTooManyTimesError) Code

func (err *TaskCalledTooManyTimesError) Code() int

func (*TaskCalledTooManyTimesError) Error

func (err *TaskCalledTooManyTimesError) Error() string

type TaskCancelledByUserError

type TaskCancelledByUserError struct {
	TaskName string
}

TaskCancelledByUserError is returned when the user does not accept an optional prompt to continue.

func (*TaskCancelledByUserError) Code

func (err *TaskCancelledByUserError) Code() int

func (*TaskCancelledByUserError) Error

func (err *TaskCancelledByUserError) Error() string

type TaskCancelledNoTerminalError

type TaskCancelledNoTerminalError struct {
	TaskName string
}

TaskCancelledNoTerminalError is returned when trying to run a task with a prompt in a non-terminal environment.

func (*TaskCancelledNoTerminalError) Code

func (err *TaskCancelledNoTerminalError) Code() int

func (*TaskCancelledNoTerminalError) Error

func (err *TaskCancelledNoTerminalError) Error() string

type TaskError

type TaskError interface {
	error
	Code() int
}

TaskError extends the standard error interface with a Code method. This code will be used as the exit code of the program which allows the user to distinguish between different types of errors.

type TaskInternalError

type TaskInternalError struct {
	TaskName string
}

TaskInternalError when the user attempts to invoke a task that is internal.

func (*TaskInternalError) Code

func (err *TaskInternalError) Code() int

func (*TaskInternalError) Error

func (err *TaskInternalError) Error() string

type TaskMissingRequiredVarsError

type TaskMissingRequiredVarsError struct {
	TaskName    string
	MissingVars []MissingVar
}

func (*TaskMissingRequiredVarsError) Code

func (err *TaskMissingRequiredVarsError) Code() int

func (*TaskMissingRequiredVarsError) Error

func (err *TaskMissingRequiredVarsError) Error() string

type TaskNameConflictError

type TaskNameConflictError struct {
	Call      string
	TaskNames []string
}

TaskNameConflictError is returned when multiple tasks with a matching name or alias are found.

func (*TaskNameConflictError) Code

func (err *TaskNameConflictError) Code() int

func (*TaskNameConflictError) Error

func (err *TaskNameConflictError) Error() string

type TaskNameFlattenConflictError

type TaskNameFlattenConflictError struct {
	TaskName string
	Include  string
}

func (*TaskNameFlattenConflictError) Code

func (err *TaskNameFlattenConflictError) Code() int

func (*TaskNameFlattenConflictError) Error

func (err *TaskNameFlattenConflictError) Error() string

type TaskNotAllowedVarsError

type TaskNotAllowedVarsError struct {
	TaskName       string
	NotAllowedVars []NotAllowedVar
}

func (*TaskNotAllowedVarsError) Code

func (err *TaskNotAllowedVarsError) Code() int

func (*TaskNotAllowedVarsError) Error

func (err *TaskNotAllowedVarsError) Error() string

type TaskNotFoundError

type TaskNotFoundError struct {
	TaskName   string
	DidYouMean string
}

TaskNotFoundError is returned when the specified task is not found in the Ritefile.

func (*TaskNotFoundError) Code

func (err *TaskNotFoundError) Code() int

func (*TaskNotFoundError) Error

func (err *TaskNotFoundError) Error() string

type TaskRunError

type TaskRunError struct {
	TaskName string
	Err      error
}

TaskRunError is returned when a command in a task returns a non-zero exit code.

func (*TaskRunError) Code

func (err *TaskRunError) Code() int

func (*TaskRunError) Error

func (err *TaskRunError) Error() string

func (*TaskRunError) TaskExitCode

func (err *TaskRunError) TaskExitCode() int

func (*TaskRunError) Unwrap

func (err *TaskRunError) Unwrap() error

type VarEnvCollisionError added in v1.0.6

type VarEnvCollisionError struct {
	Name     string
	TaskName string
}

VarEnvCollisionError is returned when a Ritefile declares the same variable name in both `vars:` and `env:` at the same scope (entrypoint top-level or a single task). Under rite's vars/env unification (SPEC §vars / env Unification), the two blocks share a single variable table — declaring the same key in both is ambiguous and the loader cannot pick a winner without silently losing the other declaration.

TaskName is empty when the collision is at the file's top level and set to the task's local name when the collision lives inside a single task.

func (*VarEnvCollisionError) Code added in v1.0.6

func (err *VarEnvCollisionError) Code() int

func (*VarEnvCollisionError) Error added in v1.0.6

func (err *VarEnvCollisionError) Error() string

Jump to

Keyboard shortcuts

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