Skip to main content

Overview

ChameleonDB provides rich, structured errors with:
  • Specific error types for different failure modes
  • Clear error messages with context
  • Actionable suggestions for resolution
  • Programmatic error inspection via error codes

Error Categories

Validation Errors

Occur before SQL generation when input doesn’t match schema.
error
Generic validation failure (field type, length, format)
error
Value type doesn’t match field type definition
error
String value exceeds maximum length
error
Invalid format (e.g., UUID, email, ISO8601)
error
Field doesn’t exist in entity schema
error
Entity doesn’t exist in schema

Constraint Errors

Occur at database level when constraints are violated.
error
Value already exists (UNIQUE constraint violation)
error
Required field is missing or null
error
Referenced record doesn’t exist
error
Cannot delete/update record with dependent records

Safety Errors

Occur when safety guards prevent potentially dangerous operations.
error
Operation blocked by safety guard (e.g., UPDATE/DELETE without WHERE)

Execution Errors

error
Record to update/delete doesn’t exist
error
Concurrent modification detected (future: optimistic locking)

Error Inspection

Type Assertions

Check for specific error types:

Error Codes

Use error codes for programmatic handling:

Error Helpers

Use helper functions to check error categories:

Common Error Scenarios

Unique Constraint Violation

Type Mismatch

Foreign Key Violation

Safety Guard

Not Null Violation

Unknown Field

Best Practices

1. Handle Specific Errors First

2. Use Error Codes for API Responses

3. Log Errors with Context

4. Provide User-Friendly Messages

Error Reference

Error Codes

Complete Example

See Also