mirror of https://github.com/djcb/mu.git
mu: improve error reporting
This commit is contained in:
parent
f2c0af7413
commit
6e37790012
|
@ -132,14 +132,10 @@ struct Store::Private {
|
||||||
|
|
||||||
} catch (const Xapian::DatabaseLockError& xde) {
|
} catch (const Xapian::DatabaseLockError& xde) {
|
||||||
throw Mu::Error(Error::Code::StoreLock,
|
throw Mu::Error(Error::Code::StoreLock,
|
||||||
"failed to lock store @ %s: %s",
|
"%s", xde.get_msg().c_str());
|
||||||
db_path.c_str(),
|
|
||||||
xde.get_msg().c_str());
|
|
||||||
} catch (const Xapian::DatabaseError& xde) {
|
} catch (const Xapian::DatabaseError& xde) {
|
||||||
throw Mu::Error(Error::Code::Store,
|
throw Mu::Error(Error::Code::Store,
|
||||||
"failed to open store @ %s: %s",
|
"%s", xde.get_msg().c_str());
|
||||||
db_path.c_str(),
|
|
||||||
xde.get_msg().c_str());
|
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
throw Mu::Error(Error::Code::Internal,
|
throw Mu::Error(Error::Code::Internal,
|
||||||
"something went wrong when opening store @ %s",
|
"something went wrong when opening store @ %s",
|
||||||
|
|
|
@ -150,7 +150,7 @@ struct Error final : public std::exception {
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr uint8_t exit_code() const {
|
constexpr uint8_t exit_code() const {
|
||||||
return ((static_cast<uint32_t>(code_) >> 15) & 0xf);
|
return ((static_cast<uint32_t>(code_) >> 15) & 0xff);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -564,12 +564,10 @@ Mu::mu_cmd_execute(const MuConfig* opts) try {
|
||||||
|
|
||||||
case MU_CONFIG_CMD_CFIND:
|
case MU_CONFIG_CMD_CFIND:
|
||||||
return with_readonly_store(mu_cmd_cfind, opts);
|
return with_readonly_store(mu_cmd_cfind, opts);
|
||||||
break;
|
|
||||||
case MU_CONFIG_CMD_FIND:
|
case MU_CONFIG_CMD_FIND:
|
||||||
return cmd_find(opts);
|
return cmd_find(opts);
|
||||||
case MU_CONFIG_CMD_INFO:
|
case MU_CONFIG_CMD_INFO:
|
||||||
return with_readonly_store(cmd_info, opts);
|
return with_readonly_store(cmd_info, opts);
|
||||||
break;
|
|
||||||
|
|
||||||
/* writable store */
|
/* writable store */
|
||||||
|
|
||||||
|
|
5
mu/mu.cc
5
mu/mu.cc
|
@ -57,7 +57,7 @@ handle_result(const Result<void>& res, MuConfig* conf)
|
||||||
if (!res.error().is_soft_error()) {
|
if (!res.error().is_soft_error()) {
|
||||||
std::cerr << col.fg(Color::Red) << "error" << col.reset() << ": "
|
std::cerr << col.fg(Color::Red) << "error" << col.reset() << ": "
|
||||||
<< col.fg(Color::BrightYellow)
|
<< col.fg(Color::BrightYellow)
|
||||||
<< res.error().what() << "something went wrong" << "\n";
|
<< res.error().what() << "\n";
|
||||||
} else
|
} else
|
||||||
std::cerr << col.fg(Color::BrightBlue) << res.error().what() << '\n';
|
std::cerr << col.fg(Color::BrightBlue) << res.error().what() << '\n';
|
||||||
|
|
||||||
|
@ -69,6 +69,9 @@ handle_result(const Result<void>& res, MuConfig* conf)
|
||||||
if (conf && mu_config_cmd_is_valid(conf->cmd))
|
if (conf && mu_config_cmd_is_valid(conf->cmd))
|
||||||
mu_config_show_help(conf->cmd);
|
mu_config_show_help(conf->cmd);
|
||||||
break;
|
break;
|
||||||
|
case Error::Code::StoreLock:
|
||||||
|
std::cerr << "Perhaps mu is already running?\n";
|
||||||
|
break;
|
||||||
case Error::Code::SchemaMismatch:
|
case Error::Code::SchemaMismatch:
|
||||||
std::cerr << "Please (re)initialize mu with 'mu init' "
|
std::cerr << "Please (re)initialize mu with 'mu init' "
|
||||||
<< "see mu-init(1) for details\n";
|
<< "see mu-init(1) for details\n";
|
||||||
|
|
Loading…
Reference in New Issue