From ab643c90ce5a4e15d42391127ccf6a68e92813af Mon Sep 17 00:00:00 2001 From: edelangh Date: Wed, 6 Sep 2017 16:50:21 +0200 Subject: [PATCH] review panic in InnerConnection.drop --- src/lib.rs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 2f2e1cf..2a83371 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -871,14 +871,17 @@ impl InnerConnection { } impl Drop for InnerConnection { - #[cfg(not(test))] #[allow(unused_must_use)] fn drop(&mut self) { - self.close(); - } - #[cfg(test)] - fn drop(&mut self) { - self.close().expect("Error while closing SQLite connection"); + use std::thread::panicking; + + if let Err(e) = self.close() { + if panicking() { + eprintln!("Error while closing SQLite connection: {:?}", e); + } else { + panic!("Error while closing SQLite connection: {:?}", e); + } + } } }