clj-r2dbc.impl.sql.error
R2DBC exception translation utilities for clj-r2dbc.
Provides:
r2dbc-ex->ex-info - converts R2dbcException to Clojure ex-info with standard keys.
wrap-error - wraps a Missionary task, translating R2dbcException on failure.
All R2DBC driver exceptions are mapped to stable :clj-r2dbc/error-category keywords.
Missionary Cancelled is never swallowed.
This namespace is an implementation detail; do not use from application code.
r2dbc-ex->ex-info
(r2dbc-ex->ex-info ex)
Convert an R2dbcException to a Clojure ex-info with standard keys.
Args:
ex - the R2dbcException to convert.
Returns an ExceptionInfo with:
:clj-r2dbc/error-category - keyword category (see r2dbc-category).
:sql-state - SQL state string from the exception.
:error-code - driver-specific error code integer.
The original R2dbcException is set as the cause.
Example:
(r2dbc-ex->ex-info (R2dbcBadGrammarException. "msg" "42000" 1234 nil))
wrap-error
(wrap-error task)
Wrap a Missionary task, translating any R2dbcException to an ex-info on failure.
Missionary Cancelled is re-thrown immediately and is never translated.
Any other exception passes through unchanged.
Args:
task - the Missionary task to wrap.
Returns a task that resolves to the same value on success, or rejects with
an ex-info (from r2dbc-ex->ex-info) when an R2dbcException is thrown.
Example:
(m/? (wrap-error (m/sp (throw (R2dbcTimeoutException. "timed out" "HYT00" 0 nil)))))