diff --git a/lib/mu-store.hh b/lib/mu-store.hh index 73dea822..a7338267 100644 --- a/lib/mu-store.hh +++ b/lib/mu-store.hh @@ -63,17 +63,10 @@ public: * @return A store or an error. */ static Result make(const std::string& path, - Options opts=Options::None) noexcept try { - return Ok(Store{path, opts}); - - } catch (const Mu::Error& me) { - return Err(me); + Options opts=Options::None) noexcept { + return xapian_try_result( + [&]{return Ok(Store{path, opts});}); } - /* LCOV_EXCL_START */ - catch (...) { - return Err(Error::Code::Internal, "failed to create store"); - } - /* LCOV_EXCL_STOP */ /** * Construct a store for a not-yet-existing document database @@ -86,18 +79,10 @@ public: */ static Result make_new(const std::string& path, const std::string& root_maildir, - Option conf={}) noexcept try { - return Ok(Store(path, root_maildir, conf)); - - } catch (const Mu::Error& me) { - return Err(me); + Option conf={}) noexcept { + return xapian_try_result( + [&]{return Ok(Store(path, root_maildir, conf));}); } - /* LCOV_EXCL_START */ - catch (...) { - return Err(Error::Code::Internal, "failed to create new store"); - } - /* LCOV_EXCL_STOP */ - /** * Move CTOR diff --git a/lib/mu-xapian-db.hh b/lib/mu-xapian-db.hh index 7380da14..94480483 100644 --- a/lib/mu-xapian-db.hh +++ b/lib/mu-xapian-db.hh @@ -76,6 +76,8 @@ template auto xapian_try_result(Func&& func) noexcept -> std::decay_t try { return func(); +} catch (const Xapian::DatabaseLockError& dlerr) { + return Err(Error::Code::StoreLock, "database locked"); } catch (const Xapian::Error& xerr) { return Err(Error::Code::Xapian, "{}", xerr.get_error_string()); } catch (const std::runtime_error& re) {