MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / pg_error_detail

Function pg_error_detail

nodedb-test-support/src/pgwire_harness/query.rs:188–199  ·  view source on GitHub ↗

Extract a detailed error message from a tokio-postgres error. tokio-postgres `Error::to_string()` just returns "db error" — useless for debugging. This pulls the actual server message out of the `DbError` when available.

(e: &tokio_postgres::Error)

Source from the content-addressed store, hash-verified

186/// debugging. This pulls the actual server message out of the `DbError` when
187/// available.
188fn pg_error_detail(e: &tokio_postgres::Error) -> String {
189 if let Some(db_err) = e.as_db_error() {
190 format!(
191 "{}: {} (SQLSTATE {})",
192 db_err.severity(),
193 db_err.message(),
194 db_err.code().code()
195 )
196 } else {
197 format!("{e:?}")
198 }
199}
200
201/// Generate a short hex string suitable for unique test name suffixes.
202fn uuid_v4_hex() -> String {

Callers 7

query_textMethod · 0.70
query_text_joinedMethod · 0.70
query_named_rowsMethod · 0.70
query_rowsMethod · 0.70
execMethod · 0.70
connect_asMethod · 0.70
expect_errorMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected