errors

package
v0.1.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	CodeNotFound      = "NOT_FOUND"
	CodeUnauthorized  = "UNAUTHORIZED"
	CodeForbidden     = "FORBIDDEN"
	CodeBadRequest    = "BAD_REQUEST"
	CodeConflict      = "CONFLICT"
	CodeInternalError = "INTERNAL_ERROR"

	CodeValidationError = "VALIDATION_ERROR"
	CodeDatabaseError   = "DATABASE_ERROR"
	CodeAuthError       = "AUTH_ERROR"
	CodeSessionError    = "SESSION_ERROR"
	CodeEpisodeError    = "EPISODE_ERROR"
	CodeEntityError     = "ENTITY_ERROR"
	CodeLLMError        = "LLM_ERROR"
	CodeConfigError     = "CONFIG_ERROR"
	CodeRateLimitError  = "RATE_LIMIT_ERROR"
	CodeCacheError      = "CACHE_ERROR"
)

Error codes for different types of errors

Variables

View Source
var (
	// General errors
	ErrNotFound      = errors.New("resource not found")
	ErrUnauthorized  = errors.New("unauthorized access")
	ErrForbidden     = errors.New("forbidden access")
	ErrInternalError = errors.New("internal server error")
	ErrBadRequest    = errors.New("bad request")
	ErrConflict      = errors.New("resource conflict")

	// Validation errors
	ErrInvalidID        = errors.New("invalid ID")
	ErrInvalidTenantID  = errors.New("invalid tenant ID")
	ErrInvalidSessionID = errors.New("invalid session ID")
	ErrInvalidText      = errors.New("invalid text")
	ErrTextTooLong      = errors.New("text too long")
	ErrInvalidEventTime = errors.New("invalid event time")
	ErrInvalidEmail     = errors.New("invalid email format")
	ErrInvalidPassword  = errors.New("invalid password")

	// Database errors
	ErrDatabaseConnection  = errors.New("database connection failed")
	ErrDatabaseQuery       = errors.New("database query failed")
	ErrDatabaseTransaction = errors.New("database transaction failed")
	ErrDuplicateKey        = errors.New("duplicate key violation")

	// Authentication errors
	ErrInvalidToken       = errors.New("invalid token")
	ErrTokenExpired       = errors.New("token expired")
	ErrInvalidCredentials = errors.New("invalid credentials")
	ErrAccountLocked      = errors.New("account locked")

	// Session errors
	ErrSessionNotFound = errors.New("session not found")
	ErrSessionExpired  = errors.New("session expired")
	ErrSessionInvalid  = errors.New("session invalid")

	// Episode errors
	ErrEpisodeNotFound     = errors.New("episode not found")
	ErrEpisodeInvalid      = errors.New("episode invalid")
	ErrEpisodeProcessing   = errors.New("episode processing failed")
	ErrEmbeddingGeneration = errors.New("embedding generation failed")

	// Entity errors
	ErrEntityNotFound   = errors.New("entity not found")
	ErrEntityInvalid    = errors.New("entity invalid")
	ErrEntityExtraction = errors.New("entity extraction failed")

	// LLM service errors
	ErrLLMServiceUnavailable = errors.New("LLM service unavailable")
	ErrLLMRateLimited        = errors.New("LLM rate limited")
	ErrLLMInvalidResponse    = errors.New("LLM invalid response")
	ErrLLMTimeout            = errors.New("LLM request timeout")

	// Configuration errors
	ErrConfigNotFound = errors.New("configuration not found")
	ErrConfigInvalid  = errors.New("configuration invalid")

	// Rate limiting errors
	ErrRateLimited = errors.New("rate limit exceeded")

	// Cache errors
	ErrCacheUnavailable = errors.New("cache unavailable")
	ErrCacheKeyNotFound = errors.New("cache key not found")
)

Common error variables for the Contextor system

Functions

func IsContextorError

func IsContextorError(err error) bool

IsContextorError checks if an error is a ContextorError

Types

type ContextorError

type ContextorError struct {
	Code    string                 `json:"code"`
	Message string                 `json:"message"`
	Details map[string]interface{} `json:"details,omitempty"`
	Cause   error                  `json:"-"`
}

ContextorError represents a structured error with additional context

func GetContextorError

func GetContextorError(err error) (*ContextorError, bool)

GetContextorError extracts a ContextorError from an error

func NewAuthError

func NewAuthError(message string, cause error) *ContextorError

func NewBadRequestError

func NewBadRequestError(message string) *ContextorError

func NewConfigError

func NewConfigError(message string) *ContextorError

func NewContextorError

func NewContextorError(code, message string, cause error) *ContextorError

NewContextorError creates a new ContextorError

func NewDatabaseError

func NewDatabaseError(operation string, cause error) *ContextorError

func NewEntityError

func NewEntityError(message string, cause error) *ContextorError

func NewEpisodeError

func NewEpisodeError(message string, cause error) *ContextorError

func NewForbiddenError

func NewForbiddenError(message string) *ContextorError

func NewLLMError

func NewLLMError(operation string, cause error) *ContextorError

func NewNotFoundError

func NewNotFoundError(resource string) *ContextorError

Predefined error constructors

func NewSessionError

func NewSessionError(message string, cause error) *ContextorError

func NewUnauthorizedError

func NewUnauthorizedError(message string) *ContextorError

func NewValidationError

func NewValidationError(field, message string) *ContextorError

func (*ContextorError) Error

func (e *ContextorError) Error() string

Error implements the error interface

func (*ContextorError) Unwrap

func (e *ContextorError) Unwrap() error

Unwrap returns the underlying error

func (*ContextorError) WithDetail

func (e *ContextorError) WithDetail(key string, value interface{}) *ContextorError

WithDetail adds a detail to the error

Jump to

Keyboard shortcuts

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