@@ -175,28 +175,36 @@ impl std::fmt::Display for Error {
175175
176176impl From < LanceError > for Error {
177177 fn from ( err : LanceError ) -> Self {
178+ let backtrace_suffix = err
179+ . backtrace ( )
180+ . map ( |bt| format ! ( "\n \n Rust backtrace:\n {}" , bt) )
181+ . unwrap_or_default ( ) ;
182+ let message = format ! ( "{}{}" , err, backtrace_suffix) ;
183+
178184 match & err {
179185 LanceError :: DatasetNotFound { .. }
180186 | LanceError :: DatasetAlreadyExists { .. }
181187 | LanceError :: CommitConflict { .. }
182- | LanceError :: InvalidInput { .. } => Self :: input_error ( err . to_string ( ) ) ,
183- LanceError :: IO { .. } => Self :: io_error ( err . to_string ( ) ) ,
184- LanceError :: NotSupported { .. } => Self :: unsupported_error ( err . to_string ( ) ) ,
185- LanceError :: NotFound { .. } => Self :: io_error ( err . to_string ( ) ) ,
188+ | LanceError :: InvalidInput { .. } => Self :: input_error ( message ) ,
189+ LanceError :: IO { .. } => Self :: io_error ( message ) ,
190+ LanceError :: NotSupported { .. } => Self :: unsupported_error ( message ) ,
191+ LanceError :: NotFound { .. } => Self :: io_error ( message ) ,
186192 LanceError :: Namespace { source, .. } => {
187193 // Try to downcast to NamespaceError and get the error code
188194 if let Some ( ns_err) = source. downcast_ref :: < NamespaceError > ( ) {
189- Self :: namespace_error ( ns_err. code ( ) . as_u32 ( ) , ns_err. to_string ( ) )
195+ let ns_message =
196+ format ! ( "{}{}" , ns_err, backtrace_suffix) ;
197+ Self :: namespace_error ( ns_err. code ( ) . as_u32 ( ) , ns_message)
190198 } else {
191199 log:: warn!(
192200 "Failed to downcast NamespaceError source, falling back to runtime error. \
193201 This may indicate a version mismatch. Source type: {:?}",
194202 source
195203 ) ;
196- Self :: runtime_error ( err . to_string ( ) )
204+ Self :: runtime_error ( message )
197205 }
198206 }
199- _ => Self :: runtime_error ( err . to_string ( ) ) ,
207+ _ => Self :: runtime_error ( message ) ,
200208 }
201209 }
202210}
0 commit comments