Help us shape the future of Go! Take the 2026 Go Developer Survey

errors

package
v0.30.1 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package errors provides sentinel errors and custom error types for the stackit application. Use errors.Is() and errors.AsType() to check for specific error types.

Package errors provides error wrapping helpers for consistent error messages.

Index

Constants

This section is empty.

Variables

View Source
var (
	Is     = errors.Is
	New    = errors.New
	Unwrap = errors.Unwrap
)

Standard library error functions wrapped for convenience

View Source
var (
	// ErrNotOnBranch indicates that HEAD is not on a branch
	ErrNotOnBranch = errors.New("not on a branch")

	// ErrNotOnBranchNoBranchSpecified indicates HEAD is not on a branch and no branch was specified
	ErrNotOnBranchNoBranchSpecified = errors.New("not on a branch and no branch specified")

	// ErrBranchNotFound indicates that a branch does not exist
	ErrBranchNotFound = errors.New("branch not found")

	// ErrRebaseNotInProgress indicates that no rebase is currently in progress
	ErrRebaseNotInProgress = errors.New("no rebase in progress")

	// ErrTrunkOperation indicates an invalid operation on the trunk branch
	ErrTrunkOperation = errors.New("invalid operation on trunk branch")

	// ErrBranchModificationRestricted indicates a branch cannot be modified due to its state (locked or frozen)
	ErrBranchModificationRestricted = errors.New("branch modification restricted")

	// ErrCanceled indicates that an interactive operation was canceled by the user
	ErrCanceled = errors.New("canceled")

	// ErrConflictWorkflow indicates a command entered the conflict-resolution
	// workflow. Resolution instructions have already been printed, so CLI
	// adapters should exit non-zero without printing this error again.
	ErrConflictWorkflow = errors.New("conflict workflow entered")

	// ErrBack indicates that the user wants to go back to the previous step
	ErrBack = errors.New("back")
)

Sentinel errors for common conditions

Functions

func AsType added in v0.30.1

func AsType[E error](err error) (E, bool)

AsType wraps the standard library's errors.AsType; generic functions cannot be aliased through a var like the helpers above.

func FailedTo

func FailedTo(action, target string, err error) error

FailedTo wraps an error with a "failed to <action> <target>" message. Returns nil if err is nil, making it safe to use in error return statements.

Example:

return errors.FailedTo("get", "branch revision", err)
// Returns: "failed to get branch revision: <underlying error>"

Types

type BranchModificationError

type BranchModificationError struct {
	BranchName string
	LockReason git.LockReason
	IsFrozen   bool
}

BranchModificationError represents an error when a branch cannot be modified

func NewBranchModificationError

func NewBranchModificationError(branchName string, lockReason git.LockReason, frozen bool) *BranchModificationError

NewBranchModificationError creates a new BranchModificationError

func (*BranchModificationError) Error

func (e *BranchModificationError) Error() string

func (*BranchModificationError) Is

func (e *BranchModificationError) Is(target error) bool

Is returns true if the target error is ErrBranchModificationRestricted

func (*BranchModificationError) IsLocked

func (e *BranchModificationError) IsLocked() bool

IsLocked returns true if the branch is locked

type ConflictWorkflowError added in v0.23.0

type ConflictWorkflowError struct {
	BranchName string
}

ConflictWorkflowError reports that a restack stopped inside the conflict workflow on a specific branch. The user-facing resolution instructions were printed before this error was returned; it exists to carry the non-zero exit code (and the message for JSON output) without a duplicate terminal print.

func NewConflictWorkflowError added in v0.23.0

func NewConflictWorkflowError(branchName string) *ConflictWorkflowError

NewConflictWorkflowError creates a new ConflictWorkflowError

func (*ConflictWorkflowError) Error added in v0.23.0

func (e *ConflictWorkflowError) Error() string

func (*ConflictWorkflowError) Is added in v0.23.0

func (e *ConflictWorkflowError) Is(target error) bool

Is returns true if the target error is ErrConflictWorkflow

Jump to

Keyboard shortcuts

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