errors

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsType

func IsType(err error, errType ErrorType) bool

IsType checks if an error is of a specific type

Types

type ErrorType

type ErrorType string

ErrorType represents the category of error

const (
	// ErrorTypeInvalidInput indicates invalid input parameters
	ErrorTypeInvalidInput ErrorType = "invalid_input"
	// ErrorTypeParsing indicates document parsing errors
	ErrorTypeParsing ErrorType = "parsing"
	// ErrorTypeEmbedding indicates embedding generation errors
	ErrorTypeEmbedding ErrorType = "embedding"
	// ErrorTypeStorage indicates vector storage errors
	ErrorTypeStorage ErrorType = "storage"
	// ErrorTypeRetrieval indicates retrieval errors
	ErrorTypeRetrieval ErrorType = "retrieval"
	// ErrorTypeLLM indicates LLM client errors
	ErrorTypeLLM ErrorType = "llm"
	// ErrorTypeConfiguration indicates configuration errors
	ErrorTypeConfiguration ErrorType = "configuration"
	// ErrorTypeNetwork indicates network-related errors
	ErrorTypeNetwork ErrorType = "network"
	// ErrorTypeTimeout indicates timeout errors
	ErrorTypeTimeout ErrorType = "timeout"
	// ErrorTypeUnknown indicates unknown errors
	ErrorTypeUnknown ErrorType = "unknown"
)

type GoRAGError

type GoRAGError struct {
	Type        ErrorType              // Error category
	Message     string                 // Error message
	Cause       error                  // Underlying error
	Suggestions []string               // Recovery suggestions
	Context     map[string]interface{} // Additional context
	DocsURL     string                 // Link to relevant documentation
}

GoRAGError represents a detailed error with context and suggestions

func ErrConfiguration

func ErrConfiguration(message string) *GoRAGError

ErrConfiguration creates a configuration error

func ErrEmbedding

func ErrEmbedding(provider string, cause error) *GoRAGError

ErrEmbedding creates an embedding error

func ErrInvalidInput

func ErrInvalidInput(message string) *GoRAGError

ErrInvalidInput creates an invalid input error

func ErrLLM

func ErrLLM(provider string, cause error) *GoRAGError

ErrLLM creates an LLM error

func ErrNetwork

func ErrNetwork(operation string, cause error) *GoRAGError

ErrNetwork creates a network error

func ErrParsing

func ErrParsing(format string, cause error) *GoRAGError

ErrParsing creates a parsing error

func ErrRetrieval

func ErrRetrieval(cause error) *GoRAGError

ErrRetrieval creates a retrieval error

func ErrStorage

func ErrStorage(operation string, cause error) *GoRAGError

ErrStorage creates a storage error

func ErrTimeout

func ErrTimeout(operation string, duration string) *GoRAGError

ErrTimeout creates a timeout error

func NewError

func NewError(errType ErrorType, message string) *GoRAGError

NewError creates a new GoRAGError

func Wrap

func Wrap(err error, errType ErrorType, message string) *GoRAGError

Wrap wraps an existing error with GoRAG error context

func (*GoRAGError) Error

func (e *GoRAGError) Error() string

Error implements the error interface

func (*GoRAGError) Is

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

Is checks if the error matches the target error type

func (*GoRAGError) Unwrap

func (e *GoRAGError) Unwrap() error

Unwrap returns the underlying error

func (*GoRAGError) WithCause

func (e *GoRAGError) WithCause(cause error) *GoRAGError

WithCause adds the underlying cause

func (*GoRAGError) WithContext

func (e *GoRAGError) WithContext(key string, value interface{}) *GoRAGError

WithContext adds context information

func (*GoRAGError) WithContextMap

func (e *GoRAGError) WithContextMap(context map[string]interface{}) *GoRAGError

WithContextMap adds multiple context entries

func (*GoRAGError) WithDocsURL

func (e *GoRAGError) WithDocsURL(url string) *GoRAGError

WithDocsURL adds a documentation link

func (*GoRAGError) WithSuggestion

func (e *GoRAGError) WithSuggestion(suggestion string) *GoRAGError

WithSuggestion adds a recovery suggestion

func (*GoRAGError) WithSuggestions

func (e *GoRAGError) WithSuggestions(suggestions ...string) *GoRAGError

WithSuggestions adds multiple recovery suggestions

Jump to

Keyboard shortcuts

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