Skip to content

Commit

Permalink
add #[track_caller] to the Row::get() functions
Browse files Browse the repository at this point in the history
This small quality-of-life improvement changes these errors:

thread '<unnamed>' panicked at /../.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-postgres-0.7.10/src/row.rs:151:25:
error retrieving column 0: error deserializing column 0: a Postgres value was `NULL`

to:

thread '<unnamed>' panicked at my-program.rs:100:25:
error retrieving column 0: error deserializing column 0: a Postgres value was `NULL`
  • Loading branch information
Charles Samuels committed Feb 16, 2024
1 parent 8989fc9 commit 289cf88
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions tokio-postgres/src/row.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ impl Row {
/// # Panics
///
/// Panics if the index is out of bounds or if the value cannot be converted to the specified type.
#[track_caller]
pub fn get<'a, I, T>(&'a self, idx: I) -> T
where
I: RowIndex + fmt::Display,
Expand Down Expand Up @@ -239,6 +240,7 @@ impl SimpleQueryRow {
/// # Panics
///
/// Panics if the index is out of bounds or if the value cannot be converted to the specified type.
#[track_caller]
pub fn get<I>(&self, idx: I) -> Option<&str>
where
I: RowIndex + fmt::Display,
Expand Down

0 comments on commit 289cf88

Please sign in to comment.