Documentation
¶
Overview ¶
Package errors provides sentinel errors and custom error types for the stackit application. Use errors.Is() and errors.As() to check for specific error types.
Package errors provides error wrapping helpers for consistent error messages.
Index ¶
Constants ¶
This section is empty.
Variables ¶
Standard library error functions wrapped for convenience
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") // ErrRebaseConflict indicates that a rebase operation encountered a conflict ErrRebaseConflict = errors.New("rebase conflict") // 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") // ErrBack indicates that the user wants to go back to the previous step ErrBack = errors.New("back") )
Sentinel errors for common conditions
Functions ¶
func FailedTo ¶
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>"
func Op ¶
Op wraps an error with an operation name context. Returns nil if err is nil, making it safe to use in error return statements.
Example:
return errors.Op("rebase", err)
// Returns: "rebase: <underlying error>"
func While ¶
While wraps an error with context about what action was being performed. Returns nil if err is nil, making it safe to use in error return statements.
Example:
return errors.While("checking branch status", err)
// Returns: "checking branch status: <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 BranchNotFoundError ¶
type BranchNotFoundError struct {
BranchName string
}
BranchNotFoundError represents an error when a branch is not found
func NewBranchNotFoundError ¶
func NewBranchNotFoundError(branchName string) *BranchNotFoundError
NewBranchNotFoundError creates a new BranchNotFoundError
func (*BranchNotFoundError) Error ¶
func (e *BranchNotFoundError) Error() string
func (*BranchNotFoundError) Is ¶
func (e *BranchNotFoundError) Is(target error) bool
Is returns true if the target error is ErrBranchNotFound
type RebaseConflictError ¶
RebaseConflictError represents an error when a rebase encounters a conflict
func NewRebaseConflictError ¶
func NewRebaseConflictError(branchName string, message string) *RebaseConflictError
NewRebaseConflictError creates a new RebaseConflictError
func (*RebaseConflictError) Error ¶
func (e *RebaseConflictError) Error() string
func (*RebaseConflictError) Is ¶
func (e *RebaseConflictError) Is(target error) bool
Is returns true if the target error is ErrRebaseConflict