Documentation
¶
Overview ¶
Package cuerrors provides utilities for enhanced error formatting and detailed error reporting when dealing with CUE language errors. It includes functionality to format errors with additional context and details using CUE's built-in error configuration system.
The main component is the Detailer type, which wraps CUE's errors.Config to provide consistent error formatting.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type DefaultDetailer ¶ added in v0.3.0
DefaultDetailer struct can be used to format CUE errors with additional details.
func NewDefaultDetailer ¶ added in v0.3.0
func NewDefaultDetailer(cwd string) DefaultDetailer
NewDefaultDetailer creates a new DefaultDetailer with the specified current working directory (cwd). In formatted errors, file paths will be made relative to this directory.
func (DefaultDetailer) ErrorWithDetails ¶ added in v0.3.0
func (d DefaultDetailer) ErrorWithDetails(err error, format string, args ...any) error
ErrorWithDetails formats an error message with additional details from the provided error.
type Detailer ¶
type Detailer interface {
// ErrorWithDetails formats an error message with additional details from the provided error.
ErrorWithDetails(err error, format string, args ...any) error
}
Detailer interface defines methods for formatting errors with additional CUE details.
func FromContext ¶
FromContext returns a Detailer from ctx or an error if no Detailer is found.
func FromContextOrEmpty ¶ added in v0.3.0
FromContextOrEmpty returns a Detailer from ctx. If no Detailer is found, this returns a EmptyDetailer.
type EmptyDetailer ¶ added in v0.3.0
type EmptyDetailer struct{}
EmptyDetailer is a Detailer implementation that does not provide any additional details. Useful when you want the error without any CUE-specific formatting.
func (EmptyDetailer) ErrorWithDetails ¶ added in v0.3.0
func (e EmptyDetailer) ErrorWithDetails(err error, format string, args ...any) error
ErrorWithDetails returns a formatted error message without any additional details.