Documentation
¶
Overview ¶
Package errors: parse stage error codes.
These constants are the stable wire format the frontend uses to map a failure to a localized "what to do about it" message. Adding a new code is non-breaking; renaming an existing one requires a coordinated frontend release because the i18n keys are looked up by code.
Codes are SCREAMING_SNAKE so they survive JSON case transforms and look distinct from Go identifiers in logs/dashboards.
Index ¶
- Constants
- Variables
- type AppError
- func IsAppError(err error) (*AppError, bool)
- func NewAgentInvalidMaxIterationsError() *AppError
- func NewAgentInvalidTemperatureError() *AppError
- func NewAgentMissingAllowedToolsError() *AppError
- func NewAgentMissingThinkingModelError() *AppError
- func NewBadRequestError(message string) *AppError
- func NewConflictError(message string) *AppError
- func NewForbiddenError(message string) *AppError
- func NewInternalServerError(message string) *AppError
- func NewModelInUseError(message string, details any) *AppError
- func NewNotFoundError(message string) *AppError
- func NewServiceUnavailableError(message string) *AppError
- func NewTenantAlreadyExistsError() *AppError
- func NewTenantCreationDisabledError() *AppError
- func NewTenantInactiveError() *AppError
- func NewTenantNotFoundError() *AppError
- func NewTooManyRequestsError(message string) *AppError
- func NewUnauthorizedError(message string) *AppError
- func NewValidationError(message string) *AppError
- func NewVectorStoreBindingInvalidError(message string) *AppError
- func NewVectorStoreUnavailableError(message string) *AppError
- type ErrorCode
Constants ¶
const ( // ErrCodeDocReaderTimeout — DocReader RPC exceeded // WEKNORA_DOCREADER_CALL_TIMEOUT (default 30m). Suggest splitting // large files or checking docreader load. ErrCodeDocReaderTimeout = "DOCREADER_TIMEOUT" // requested file type / engine, or the service refused connection. ErrCodeDocReaderUnavailable = "DOCREADER_UNAVAILABLE" // ErrCodeDocReaderParseFailed — DocReader returned an explicit parse // error (encoding, corrupted file, OCR engine crash, ...). ErrCodeDocReaderParseFailed = "DOCREADER_PARSE_FAILED" // ErrCodeChunkingFailed — text chunking step itself failed (rare; // usually only on extreme-size inputs). ErrCodeChunkingFailed = "CHUNKING_FAILED" // ErrCodeEmbeddingRateLimit — embedding provider returned 429 or // equivalent. Suggest retrying later or scaling out. ErrCodeEmbeddingRateLimit = "EMBEDDING_RATE_LIMIT" // ErrCodeEmbeddingProviderFail — non-rate-limit embedding error // (auth, model not found, bad input). Usually permanent without // config changes. ErrCodeEmbeddingProviderFail = "EMBEDDING_PROVIDER_FAIL" // ErrCodeVectorStoreWriteFailed — chunks embedded fine but the // vector DB write failed (quota, connectivity, schema mismatch). ErrCodeVectorStoreWriteFailed = "VECTORSTORE_WRITE_FAILED" // ErrCodeMultimodalVLMFailed — a single image's OCR or caption call // failed. Note: per-image failures don't fail the whole parent; // see image_multimodal.go finalize-on-last-attempt. ErrCodeMultimodalVLMFailed = "MULTIMODAL_VLM_FAILED" // ErrCodeMultimodalAllFailed — every image task hit dead-letter. // The parent still completes (caption / OCR is optional content), // but stage status is marked failed so the UI can warn. ErrCodeMultimodalAllFailed = "MULTIMODAL_ALL_FAILED" // ErrCodeTaskTimeout — asynq retry budget exhausted. Used by the // dead-letter callback when promoting a task failure into a stage // failure. Distinct from DocReaderTimeout: this is the asynq-level // timeout (whole task), not the docreader-call-level timeout. ErrCodeTaskTimeout = "TASK_TIMEOUT" // ErrCodeTaskStalled — housekeeping found no progress for longer than // the stale threshold with nothing left queued, and failed the row. ErrCodeTaskStalled = "TASK_STALLED" // ErrCodeUnknown — fallback when a wrapped error doesn't classify. // The full message is still recorded in error_detail so operators // can debug; the UI shows a generic "see admin" hint. ErrCodeUnknown = "UNKNOWN" )
Variables ¶
var ( // ErrSessionNotFound session not found error ErrSessionNotFound = errors.New("session not found") // ErrSessionExpired session expired error ErrSessionExpired = errors.New("session expired") // ErrSessionLimitExceeded session limit exceeded error ErrSessionLimitExceeded = errors.New("session limit exceeded") // ErrInvalidSessionID invalid session ID error ErrInvalidSessionID = errors.New("invalid session id") // ErrInvalidTenantID invalid tenant ID error ErrInvalidTenantID = errors.New("invalid tenant id") )
Functions ¶
This section is empty.
Types ¶
type AppError ¶
type AppError struct {
Code ErrorCode `json:"code"`
Message string `json:"message"`
Details any `json:"details,omitempty"`
HTTPCode int `json:"-"`
}
AppError defines the application error structure
func IsAppError ¶
IsAppError checks if the error is an AppError type
func NewAgentInvalidMaxIterationsError ¶
func NewAgentInvalidMaxIterationsError() *AppError
func NewAgentInvalidTemperatureError ¶
func NewAgentInvalidTemperatureError() *AppError
func NewAgentMissingAllowedToolsError ¶
func NewAgentMissingAllowedToolsError() *AppError
func NewAgentMissingThinkingModelError ¶
func NewAgentMissingThinkingModelError() *AppError
Agent related errors
func NewBadRequestError ¶
NewBadRequestError creates a bad request error
func NewConflictError ¶
NewConflictError creates a conflict error
func NewForbiddenError ¶
NewForbiddenError creates a forbidden error
func NewInternalServerError ¶
NewInternalServerError creates an internal server error
func NewModelInUseError ¶
NewModelInUseError creates the typed HTTP 400 returned when active tenant resources still reference a model.
func NewNotFoundError ¶
NewNotFoundError creates a not found error
func NewServiceUnavailableError ¶
NewServiceUnavailableError creates a service unavailable (503) error. Used for transient failures where the caller can retry.
func NewTenantAlreadyExistsError ¶
func NewTenantAlreadyExistsError() *AppError
NewTenantAlreadyExistsError creates a tenant already exists error
func NewTenantCreationDisabledError ¶
func NewTenantCreationDisabledError() *AppError
NewTenantCreationDisabledError reports a deployment-policy denial for ordinary self-service tenant creation.
func NewTenantInactiveError ¶
func NewTenantInactiveError() *AppError
NewTenantInactiveError creates a tenant inactive error
func NewTooManyRequestsError ¶
NewTooManyRequestsError creates a 429 error, used by quota-style guards (e.g. per-user self-service tenant creation cap).
func NewUnauthorizedError ¶
NewUnauthorizedError creates an unauthorized error
func NewValidationError ¶
NewValidationError creates a validation error
func NewVectorStoreBindingInvalidError ¶
NewVectorStoreBindingInvalidError signals that a knowledge base create request referenced a vector store that does not exist under the caller's tenant (or carried a malformed UUID). The user-facing message is intentionally generic to avoid enumeration oracles — see the structured log at the call site for the tenant/store pair.
func NewVectorStoreUnavailableError ¶
NewVectorStoreUnavailableError signals that the requested vector store row exists in the database but is not currently wired into the in-memory engine registry (factory failure on CreateStore, dynamic config error, or stale state after a connection-config rotation).
func (*AppError) WithDetails ¶
WithDetails adds error details
type ErrorCode ¶
type ErrorCode int
ErrorCode defines the error code type
const ( // Common error codes (1000-1999) ErrBadRequest ErrorCode = 1000 ErrForbidden ErrorCode = 1002 ErrNotFound ErrorCode = 1003 ErrMethodNotAllowed ErrorCode = 1004 ErrConflict ErrorCode = 1005 ErrTooManyRequests ErrorCode = 1006 ErrInternalServer ErrorCode = 1007 ErrTimeout ErrorCode = 1009 ErrValidation ErrorCode = 1010 // Tenant related error codes (2000-2099) ErrTenantNotFound ErrorCode = 2000 ErrTenantAlreadyExists ErrorCode = 2001 ErrTenantInactive ErrorCode = 2002 ErrTenantNameRequired ErrorCode = 2003 ErrTenantInvalidStatus ErrorCode = 2004 ErrTenantCreationDisabled ErrorCode = 2005 // Agent related error codes (2100-2199) ErrAgentMissingThinkingModel ErrorCode = 2100 ErrAgentMissingAllowedTools ErrorCode = 2101 ErrAgentInvalidMaxIterations ErrorCode = 2102 ErrAgentInvalidTemperature ErrorCode = 2103 // VectorStore binding related error codes (2200-2299). // Both map to HTTP 400 with a generic message; the typed code lets // clients distinguish "wrong UUID / cross-tenant" from "store exists // but is currently unavailable" without parsing the message text. ErrVectorStoreBindingInvalid ErrorCode = 2200 // Model lifecycle errors (2300-2399). // The dedicated code lets clients render structured usage details without // parsing the backwards-compatible English error message. ErrModelInUse ErrorCode = 2300 )
System error codes