Add feature to compile early panics
Do debug printing when drop of FileLockEntry failed.
This commit is contained in:
parent
7b3f28eb0a
commit
e8f4a9089a
5 changed files with 54 additions and 1 deletions
|
@ -34,3 +34,6 @@ path = "../libimagutil"
|
|||
[dependencies.libimagerror]
|
||||
path = "../libimagerror"
|
||||
|
||||
[features]
|
||||
early-panic = [ "libimagstore/early-panic" ]
|
||||
|
||||
|
|
|
@ -39,3 +39,8 @@ env_logger = "0.3"
|
|||
default = []
|
||||
verify = []
|
||||
|
||||
# Enable panic!()s if critical errors occur.
|
||||
# Can be used to debug the store more intensly via the imag-store commandline
|
||||
# application
|
||||
early-panic=[]
|
||||
|
||||
|
|
|
@ -46,6 +46,8 @@ extern crate walkdir;
|
|||
#[macro_use] extern crate libimagerror;
|
||||
#[macro_use] extern crate libimagutil;
|
||||
|
||||
#[macro_use] mod util;
|
||||
|
||||
pub mod storeid;
|
||||
pub mod error;
|
||||
pub mod hook;
|
||||
|
|
|
@ -942,7 +942,15 @@ impl<'a> DerefMut for FileLockEntry<'a> {
|
|||
impl<'a> Drop for FileLockEntry<'a> {
|
||||
/// This will silently ignore errors, use `Store::update` if you want to catch the errors
|
||||
fn drop(&mut self) {
|
||||
let _ = self.store._update(self, true);
|
||||
use libimagerror::trace::trace_error_dbg;
|
||||
|
||||
match self.store._update(self, true) {
|
||||
Err(e) => {
|
||||
trace_error_dbg(&e);
|
||||
if_cfg_panic!("ERROR WHILE DROPPING: {:?}", e);
|
||||
},
|
||||
Ok(_) => { },
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
35
libimagstore/src/util.rs
Normal file
35
libimagstore/src/util.rs
Normal file
|
@ -0,0 +1,35 @@
|
|||
//
|
||||
// imag - the personal information management suite for the commandline
|
||||
// Copyright (C) 2015, 2016 Matthias Beyer <mail@beyermatthias.de> and contributors
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; version
|
||||
// 2.1 of the License.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
//
|
||||
|
||||
#[cfg(feature = "early-panic")]
|
||||
#[macro_export]
|
||||
macro_rules! if_cfg_panic {
|
||||
() => { panic!() };
|
||||
($msg:expr) => { panic!($msg) };
|
||||
($fmt:expr, $($arg:tt)+) => { panic!($fmt, $($($arg),*)) };
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "early-panic"))]
|
||||
#[macro_export]
|
||||
macro_rules! if_cfg_panic {
|
||||
() => { };
|
||||
($msg:expr) => { };
|
||||
($fmt:expr, $($arg:tt)+) => { };
|
||||
}
|
||||
|
Loading…
Reference in a new issue