Documentation
¶
Overview ¶
Package ux provides user-experience primitives for structured CLI error display. It wraps the errs.CLIError type with richer terminal rendering.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type UXError ¶
type UXError struct {
// Code is the short error code (e.g. "E001").
Code string
// What is a plain-language description of what happened.
What string
// Why is the root cause.
Why string
// Suggestions is a list of actionable fix steps shown as a numbered list.
Suggestions []string
// DocsLink is the full URL to the error reference page.
DocsLink string
// Wrapped is an optional underlying error for errors.Is/As.
Wrapped error
}
UXError is the display layer for a CLIError. It holds a structured error and renders it with colored terminal output, including what/why/suggestions/docs-link/error-code sections.
func FromCLIError ¶
FromCLIError converts an errs.CLIError to a UXError for rendering.
func New ¶
New creates a UXError from the error registry. Falls back to a generic error when the code is not registered.
func (*UXError) Print ¶
func (e *UXError) Print()
Print renders the UXError to stderr with ANSI formatting.
func (*UXError) PrintAndReturn ¶
PrintAndReturn prints the error to stderr and returns it as a plain error, so call sites can write: return ux.Newf("E001", "...").WithWhy("...").PrintAndReturn()
func (*UXError) WithSuggestions ¶
WithSuggestions returns a copy of the error with additional suggestions.