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)
| 186 | /// debugging. This pulls the actual server message out of the `DbError` when |
| 187 | /// available. |
| 188 | fn 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. |
| 202 | fn uuid_v4_hex() -> String { |
no outgoing calls
no test coverage detected