Documentation
¶
Index ¶
- Constants
- Variables
- func IsContextorError(err error) bool
- type ContextorError
- func GetContextorError(err error) (*ContextorError, bool)
- func NewAuthError(message string, cause error) *ContextorError
- func NewBadRequestError(message string) *ContextorError
- func NewConfigError(message string) *ContextorError
- func NewContextorError(code, message string, cause error) *ContextorError
- func NewDatabaseError(operation string, cause error) *ContextorError
- func NewEntityError(message string, cause error) *ContextorError
- func NewEpisodeError(message string, cause error) *ContextorError
- func NewForbiddenError(message string) *ContextorError
- func NewLLMError(operation string, cause error) *ContextorError
- func NewNotFoundError(resource string) *ContextorError
- func NewSessionError(message string, cause error) *ContextorError
- func NewUnauthorizedError(message string) *ContextorError
- func NewValidationError(field, message string) *ContextorError
Constants ¶
View Source
const ( CodeNotFound = "NOT_FOUND" 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") 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 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 ErrCacheKeyNotFound = errors.New("cache key not found") )
Common error variables for the Contextor system
Functions ¶
func IsContextorError ¶
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
Click to show internal directories.
Click to hide internal directories.