cuerrors

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

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

func NewContext

func NewContext(ctx context.Context, detailer Detailer) context.Context

NewContext returns a new Context, derived from ctx, which carries the provided Detailer.

Types

type DefaultDetailer added in v0.3.0

type DefaultDetailer struct {
	Cfg errors.Config
}

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

func FromContext(ctx context.Context) (Detailer, error)

FromContext returns a Detailer from ctx or an error if no Detailer is found.

func FromContextOrEmpty added in v0.3.0

func FromContextOrEmpty(ctx context.Context) Detailer

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.

Jump to

Keyboard shortcuts

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