From 561ae83998bec578184b2389235d52edb0118d54 Mon Sep 17 00:00:00 2001
From: Martin Tzvetanov Grigorov <mgrigorov@apache.org>
Date: Tue, 10 Oct 2023 22:57:16 +0300
Subject: [PATCH] AVRO-3779: Minor improvements in the error handling

Signed-off-by: Martin Tzvetanov Grigorov <mgrigorov@apache.org>
---
 lang/rust/avro/src/decimal.rs | 2 +-
 lang/rust/avro/src/error.rs   | 8 ++++----
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/lang/rust/avro/src/decimal.rs b/lang/rust/avro/src/decimal.rs
index da5cb35f00f..4237d710878 100644
--- a/lang/rust/avro/src/decimal.rs
+++ b/lang/rust/avro/src/decimal.rs
@@ -126,7 +126,7 @@ pub(crate) fn deserialize_big_decimal(bytes: &Vec<u8>) -> Result<BigDecimal, Err
     let mut bytes: &[u8] = bytes.as_slice();
     let mut big_decimal_buffer = match decode_len(&mut bytes) {
         Ok(size) => vec![0u8; size],
-        Err(_err) => return Err(Error::BigDecimalLen),
+        Err(err) => return Err(Error::BigDecimalLen(Box::new(err))),
     };
 
     bytes
diff --git a/lang/rust/avro/src/error.rs b/lang/rust/avro/src/error.rs
index 1487296a716..7b27ad57b55 100644
--- a/lang/rust/avro/src/error.rs
+++ b/lang/rust/avro/src/error.rs
@@ -292,13 +292,13 @@ pub enum Error {
     #[error("The decimal precision ({precision}) must be a positive number")]
     DecimalPrecisionMuBePositive { precision: usize },
 
-    #[error("Unreadable decimal sign")]
+    #[error("Unreadable big decimal sign")]
     BigDecimalSign,
 
-    #[error("Unreadable length for decimal inner bytes")]
-    BigDecimalLen,
+    #[error("Unreadable length for big decimal inner bytes: {0}")]
+    BigDecimalLen(#[source] Box<Error>),
 
-    #[error("Unreadable decimal scale")]
+    #[error("Unreadable big decimal scale")]
     BigDecimalScale,
 
     #[error("Unexpected `type` {0} variant for `logicalType`")]