Prax provides comprehensive error types with unique error codes, actionable suggestions, and helpful context to quickly diagnose and fix issues.
Use pattern matching or boolean checks to handle different error types.
Every error has a unique code in the Pxxxx format for easy identification and documentation lookup.
| Range | Category | Description |
|---|---|---|
P1xxx |
Query | Record not found, invalid filters |
P2xxx |
Constraint | Unique, foreign key, not null violations |
P3xxx |
Connection | Connection failures, pool exhausted, auth |
P4xxx |
Transaction | Deadlocks, serialization failures |
P5xxx |
Execution | Timeouts, syntax errors |
P6xxx |
Data | Type mismatches, serialization |
P7xxx |
Configuration | Invalid config, missing settings |
P9xxx |
Internal | Internal errors, bugs |
Errors include suggestions for how to fix the issue, with code examples when applicable.
Use display_colored() for beautiful terminal output with ANSI colors.
Enrich errors with additional context for better debugging.
Create custom errors quickly with the query_error! macro.
Use boolean methods to check error categories without pattern matching.
The is_retryable() check identifies transient errors that
are safe to retry: connection timeouts, pool exhaustion, deadlocks, and serialization failures.
Use this with the RetryMiddleware for automatic handling.