mirror of https://github.com/djcb/mu.git
parent
d374d94031
commit
72f43f11df
|
@ -63,17 +63,10 @@ public:
|
||||||
* @return A store or an error.
|
* @return A store or an error.
|
||||||
*/
|
*/
|
||||||
static Result<Store> make(const std::string& path,
|
static Result<Store> make(const std::string& path,
|
||||||
Options opts=Options::None) noexcept try {
|
Options opts=Options::None) noexcept {
|
||||||
return Ok(Store{path, opts});
|
return xapian_try_result(
|
||||||
|
[&]{return Ok(Store{path, opts});});
|
||||||
} catch (const Mu::Error& me) {
|
|
||||||
return Err(me);
|
|
||||||
}
|
}
|
||||||
/* 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
|
* Construct a store for a not-yet-existing document database
|
||||||
|
@ -86,18 +79,10 @@ public:
|
||||||
*/
|
*/
|
||||||
static Result<Store> make_new(const std::string& path,
|
static Result<Store> make_new(const std::string& path,
|
||||||
const std::string& root_maildir,
|
const std::string& root_maildir,
|
||||||
Option<const Config&> conf={}) noexcept try {
|
Option<const Config&> conf={}) noexcept {
|
||||||
return Ok(Store(path, root_maildir, conf));
|
return xapian_try_result(
|
||||||
|
[&]{return Ok(Store(path, root_maildir, conf));});
|
||||||
} catch (const Mu::Error& me) {
|
|
||||||
return Err(me);
|
|
||||||
}
|
}
|
||||||
/* LCOV_EXCL_START */
|
|
||||||
catch (...) {
|
|
||||||
return Err(Error::Code::Internal, "failed to create new store");
|
|
||||||
}
|
|
||||||
/* LCOV_EXCL_STOP */
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Move CTOR
|
* Move CTOR
|
||||||
|
|
|
@ -76,6 +76,8 @@ template <typename Func> auto
|
||||||
xapian_try_result(Func&& func) noexcept -> std::decay_t<decltype(func())>
|
xapian_try_result(Func&& func) noexcept -> std::decay_t<decltype(func())>
|
||||||
try {
|
try {
|
||||||
return func();
|
return func();
|
||||||
|
} catch (const Xapian::DatabaseLockError& dlerr) {
|
||||||
|
return Err(Error::Code::StoreLock, "database locked");
|
||||||
} catch (const Xapian::Error& xerr) {
|
} catch (const Xapian::Error& xerr) {
|
||||||
return Err(Error::Code::Xapian, "{}", xerr.get_error_string());
|
return Err(Error::Code::Xapian, "{}", xerr.get_error_string());
|
||||||
} catch (const std::runtime_error& re) {
|
} catch (const std::runtime_error& re) {
|
||||||
|
|
Loading…
Reference in New Issue