Handle database errors
Common SQLSTATE classes
Section titled “Common SQLSTATE classes”| Code | Meaning | Application response |
|---|---|---|
23505 |
Duplicate value for a uniqueness constraint | Reconcile identifiers or return an application conflict |
40001 |
Transaction conflict | Roll back and retry the complete transaction with a bounded policy |
25P02 |
Transaction is already aborted | Roll back before issuing new work |
42601 |
SQL syntax error | Correct the statement; repeated retries will not fix it |
0A000 |
Unsupported feature | Use a supported operation or redesign the integration |
53200 |
Memory/resource failure | Reduce the work or adjust a reviewed resource budget |
57014 |
Query cancellation | Check timeout or cancellation policy and reconcile uncertain writes |
Client libraries expose errors differently. Inspect their structured error fields rather than parsing display text when possible.
Uncertain writes
Section titled “Uncertain writes”A disconnected client may not know whether a commit completed. Use stable request identifiers and read the recorded state before retrying a non-idempotent operation.
Diagnostics
Section titled “Diagnostics”Record the server version, client version, operation and error code. Remove credentials and private values from shared reports.