diff --git a/sqlx-core/src/postgres/types/bigdecimal.rs b/sqlx-core/src/postgres/types/bigdecimal.rs index ff5e3e1a..b87ea571 100644 --- a/sqlx-core/src/postgres/types/bigdecimal.rs +++ b/sqlx-core/src/postgres/types/bigdecimal.rs @@ -125,8 +125,9 @@ impl TryFrom for BigDecimal { cents.push((digit % 100) as u8); } - let bigint = BigInt::from_radix_be(sign, ¢s, 100) - .expect("BUG digit outside of given radix, check math above"); + let bigint = BigInt::from_radix_be(sign, ¢s, 100).ok_or_else(|e| { + crate::Error::Decode("PgNumeric contained an out-of-range digit".into()) + })?; Ok(BigDecimal::new(bigint, scale)) }