errors

package
v0.0.13 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2025 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(code ErrorCode, message string) error

New creates a new error with a code and message.

func WithFields

func WithFields(err error, fields Fields) error

WithFields adds structured context to an error.

func Wrap

func Wrap(err error, code ErrorCode, message string) error

Wrap wraps an existing error with additional context.

Types

type Error

type Error struct {
	// contains filtered or unexported fields
}

Error represents a structured error with context.

func (*Error) As

func (e *Error) As(target interface{}) bool

As implements error type casting for errors.As.

func (*Error) Code

func (e *Error) Code() ErrorCode

func (*Error) Error

func (e *Error) Error() string

func (*Error) Fields

func (e *Error) Fields() Fields

func (*Error) Is

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

Is implements error matching.

func (*Error) Unwrap

func (e *Error) Unwrap() error

type ErrorCode

type ErrorCode int

ErrorCode defines known error types in the system.

const (
	// Core error codes.
	Unknown ErrorCode = iota
	InvalidInput
	ValidationFailed
	ResourceNotFound
	Timeout
	RateLimitExceeded
	Canceled
	ResourceExhausted // For scenarios where a resource limit is reached
	// LLM specific errors.
	LLMGenerationFailed
	TokenLimitExceeded
	InvalidResponse
	ModelNotSupported
	ProviderNotFound
	ConfigurationError
	UnsupportedOperation

	// Workflow errors.
	WorkflowExecutionFailed
	StepExecutionFailed
	InvalidWorkflowState
)

type Fields

type Fields map[string]interface{}

Fields carries structured data about the error.

Jump to

Keyboard shortcuts

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