From 764ee0b0c58eb98e64d6383260793fa5a1d068a8 Mon Sep 17 00:00:00 2001 From: Joe Thornber Date: Fri, 11 Oct 2013 11:04:06 +0100 Subject: [PATCH] [cache_check] tweak exception handling; there was a window where they weren't caught --- caching/cache_check.cc | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/caching/cache_check.cc b/caching/cache_check.cc index dea9f24..cbe4581 100644 --- a/caching/cache_check.cc +++ b/caching/cache_check.cc @@ -276,17 +276,25 @@ namespace { throw runtime_error(msg.str()); } + block_manager<>::ptr bm = open_bm(path, block_io<>::READ_ONLY); + err = metadata_check(bm, fs); + + return err == NO_ERROR ? 0 : 1; + } + + int check_with_exception_handling(string const &path, flags const &fs) { + int r; try { - block_manager<>::ptr bm = open_bm(path, block_io<>::READ_ONLY); - err = metadata_check(bm, fs); + r = check(path, fs); } catch (std::exception &e) { if (!fs.quiet_) cerr << e.what() << endl; - return 1; + r = 1; } - return err == NO_ERROR ? 0 : 1; + return r; + } void usage(ostream &out, string const &cmd) { @@ -363,7 +371,7 @@ int main(int argc, char **argv) return 1; } - return check(argv[optind], fs); + return check_with_exception_handling(argv[optind], fs); } //----------------------------------------------------------------