errors

package
v1.3.10 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package errors provides structured error types for ReleasePilot. It implements error classification, wrapping, and recovery detection.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsKind

func IsKind(err error, kind Kind) bool

IsKind checks if an error is of a specific kind.

func IsRecoverable

func IsRecoverable(err error) bool

IsRecoverable returns true if the error is recoverable.

func IsSensitive

func IsSensitive(s string) bool

IsSensitive checks if a string contains sensitive patterns.

func RedactError

func RedactError(err error) error

RedactError creates a new error with sensitive data redacted from its message. If the error is nil, returns nil.

func RedactSensitive

func RedactSensitive(s string) string

RedactSensitive removes sensitive information from an error message. It redacts API keys, tokens, and other secrets that should not appear in logs.

Types

type Error

type Error struct {
	// Kind is the category of the error.
	Kind Kind
	// Op is the operation being performed when the error occurred.
	Op string
	// Message is a human-readable error message.
	Message string
	// Err is the underlying error.
	Err error
	// Recoverable indicates if the error can be recovered from.
	Recoverable bool
	// Details contains additional context about the error.
	Details map[string]any
}

Error is the standard error type for ReleasePilot.

func AI

func AI(op, message string) *Error

AI creates an AI service error.

func AIWrap

func AIWrap(err error, op, message string) *Error

AIWrap wraps an error as an AI service error.

func AIWrapSafe

func AIWrapSafe(err error, op, message string) *Error

AIWrapSafe wraps an error as an AI service error with sensitive data redacted. Use this instead of AIWrap when the underlying error might contain API keys or tokens.

func Config

func Config(op, message string) *Error

Config creates a configuration error.

func ConfigWrap

func ConfigWrap(err error, op, message string) *Error

ConfigWrap wraps an error as a configuration error.

func Conflict

func Conflict(op, message string) *Error

Conflict creates a conflict error.

func ConflictWrap

func ConflictWrap(err error, op, message string) *Error

ConflictWrap wraps an error as a conflict error.

func E

func E(args ...any) *Error

E is a convenience function to create errors with various arguments. Arguments can be of type Kind, string (operation), error, or map[string]any (details).

func Git

func Git(op, message string) *Error

Git creates a git operation error.

func GitWrap

func GitWrap(err error, op, message string) *Error

GitWrap wraps an error as a git error.

func IO

func IO(op, message string) *Error

IO creates an I/O error.

func IOWrap

func IOWrap(err error, op, message string) *Error

IOWrap wraps an error as an I/O error.

func Internal

func Internal(op, message string) *Error

Internal creates an internal error.

func InternalWrap

func InternalWrap(err error, op, message string) *Error

InternalWrap wraps an error as an internal error.

func Network

func Network(op, message string) *Error

Network creates a network error.

func NetworkWrap

func NetworkWrap(err error, op, message string) *Error

NetworkWrap wraps an error as a network error.

func New

func New(kind Kind, message string) *Error

New creates a new Error with the given kind and message.

func Newf

func Newf(kind Kind, format string, args ...any) *Error

Newf creates a new Error with the given kind and formatted message.

func NotFound

func NotFound(op, message string) *Error

NotFound creates a not found error.

func NotFoundWrap

func NotFoundWrap(err error, op, message string) *Error

NotFoundWrap wraps an error as a not found error.

func Plugin

func Plugin(op, message string) *Error

Plugin creates a plugin error.

func PluginWrap

func PluginWrap(err error, op, message string) *Error

PluginWrap wraps an error as a plugin error.

func State

func State(op, message string) *Error

State creates a state management error.

func StateWrap

func StateWrap(err error, op, message string) *Error

StateWrap wraps an error as a state management error.

func Template

func Template(op, message string) *Error

Template creates a template error.

func TemplateWrap

func TemplateWrap(err error, op, message string) *Error

TemplateWrap wraps an error as a template error.

func Timeout

func Timeout(op, message string) *Error

Timeout creates a timeout error.

func TimeoutWrap

func TimeoutWrap(err error, op, message string) *Error

TimeoutWrap wraps an error as a timeout error.

func Validation

func Validation(op, message string) *Error

Validation creates a validation error.

func ValidationWrap

func ValidationWrap(err error, op, message string) *Error

ValidationWrap wraps an error as a validation error.

func Version

func Version(op, message string) *Error

Version creates a versioning error.

func VersionWrap

func VersionWrap(err error, op, message string) *Error

VersionWrap wraps an error as a versioning error.

func Wrap

func Wrap(err error, kind Kind, op string, message string) *Error

Wrap wraps an existing error with additional context.

func WrapSafe

func WrapSafe(err error, kind Kind, op, message string) *Error

WrapSafe wraps an error with sensitive data redacted.

func Wrapf

func Wrapf(err error, kind Kind, op string, format string, args ...any) *Error

Wrapf wraps an existing error with a formatted message.

func (*Error) Error

func (e *Error) Error() string

Error implements the error interface.

func (*Error) Is

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

Is reports whether the target error matches this error. For *Error types, it checks if both the Kind and Op match. For sentinel errors (errors without Op), only Kind is compared.

func (*Error) Unwrap

func (e *Error) Unwrap() error

Unwrap returns the underlying error.

func (*Error) WithDetail

func (e *Error) WithDetail(key string, value any) *Error

WithDetail adds a single detail to the error and returns the modified error.

func (*Error) WithDetails

func (e *Error) WithDetails(details map[string]any) *Error

WithDetails adds details to the error and returns the modified error.

type Kind

type Kind uint8

Kind represents the category of an error.

const (
	// KindUnknown indicates an error of unknown type.
	KindUnknown Kind = iota
	// KindConfig indicates a configuration error.
	KindConfig
	// KindGit indicates a git operation error.
	KindGit
	// KindVersion indicates a versioning error.
	KindVersion
	// KindPlugin indicates a plugin error.
	KindPlugin
	// KindAI indicates an AI service error.
	KindAI
	// KindTemplate indicates a template rendering error.
	KindTemplate
	// KindState indicates a state management error.
	KindState
	// KindNetwork indicates a network error.
	KindNetwork
	// KindIO indicates a file I/O error.
	KindIO
	// KindValidation indicates a validation error.
	KindValidation
	// KindPermission indicates a permission error.
	KindPermission
	// KindNotFound indicates a resource was not found.
	KindNotFound
	// KindConflict indicates a conflict error.
	KindConflict
	// KindTimeout indicates a timeout error.
	KindTimeout
	// KindCanceled indicates the operation was canceled.
	KindCanceled
	// KindInternal indicates an internal error.
	KindInternal
)

func GetKind

func GetKind(err error) Kind

GetKind returns the Kind of an error. If the error is not an *Error, it returns KindUnknown.

func (Kind) String

func (k Kind) String() string

String returns a human-readable string for the error kind.

Jump to

Keyboard shortcuts

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