errors

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package errors provides custom error types for user-friendly error messaging.

This package distinguishes between user-facing errors and technical errors, allowing the CLI to display clean messages while preserving technical details for debugging with verbose flags.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type UserError

type UserError struct {
	// Message is the user-friendly error message displayed to users.
	Message string

	// Err is the underlying technical error, preserved for debugging
	// but hidden from normal output.
	Err error

	// Hint provides actionable guidance to help users resolve the issue.
	Hint string
}

UserError represents an error with a user-friendly message.

UserError separates user-facing messages from technical implementation details, making CLI output cleaner while preserving debugging information for verbose mode.

func IsUserError

func IsUserError(err error) (*UserError, bool)

IsUserError checks whether an error chain contains a UserError.

It uses errors.As to walk the error chain and returns the first UserError found. The second return value indicates whether a UserError was found.

func NewUserError

func NewUserError(message string) *UserError

NewUserError creates a user-facing error with a message.

Use this for simple errors that don't need hints or wrapped technical errors.

func NewUserErrorWithHint

func NewUserErrorWithHint(message, hint string) *UserError

NewUserErrorWithHint creates a user-facing error with a message and actionable hint.

The hint should provide specific instructions to help users resolve the issue, such as command examples or documentation links.

func WrapUserError

func WrapUserError(message string, err error) *UserError

WrapUserError wraps a technical error with a user-friendly message.

The technical error is preserved for debugging with verbose flags but hidden from normal output.

func WrapUserErrorWithHint

func WrapUserErrorWithHint(message, hint string, err error) *UserError

WrapUserErrorWithHint wraps a technical error with a user-friendly message and hint.

This combines a clean user message, actionable guidance, and technical details for debugging.

func (*UserError) Error

func (e *UserError) Error() string

Error implements the error interface and returns the user-friendly message.

If a hint is set, it appends the hint to the message on a new line.

func (*UserError) Unwrap

func (e *UserError) Unwrap() error

Unwrap returns the underlying technical error for error chain inspection.

Jump to

Keyboard shortcuts

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