summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDirk-Jan C. Binnema <djcb@djcbsoftware.nl>2021-07-31 01:48:24 +0300
committerDirk-Jan C. Binnema <djcb@djcbsoftware.nl>2021-07-31 01:48:24 +0300
commit8a3a125ca37c3f2920b5d77200bb557e25d01f66 (patch)
tree5521bae3e51740a9aa9a58e74c49cd95e178f370
parentfd9cc6bcc4c98b211132374f6a4b0f1073793f18 (diff)
mu-cmd-server: report errors to mu4e
Even "existential errors" that cause mu-server not to start.
-rw-r--r--mu/mu-cmd-server.cc18
1 files changed, 15 insertions, 3 deletions
diff --git a/mu/mu-cmd-server.cc b/mu/mu-cmd-server.cc
index 82c6095..6185731 100644
--- a/mu/mu-cmd-server.cc
+++ b/mu/mu-cmd-server.cc
@@ -87,6 +87,17 @@ output_sexp_stdout (Sexp&& sexp)
}
}
+static void
+report_error(const Mu::Error& err) noexcept
+{
+ Sexp::List e;
+
+ e.add_prop(":error", Sexp::make_number(static_cast<size_t>(err.code())));
+ e.add_prop(":message", Sexp::make_string(err.what()));
+
+ output_sexp_stdout(Sexp::make_list(std::move(e)));
+}
+
MuError
Mu::mu_cmd_server (const MuConfig *opts, GError **err) try {
@@ -130,9 +141,10 @@ Mu::mu_cmd_server (const MuConfig *opts, GError **err) try {
return MU_OK;
} catch (const Error& er) {
- g_critical ("server caught exception: %s", er.what());
- g_set_error(err, MU_ERROR_DOMAIN, MU_ERROR, "%s", er.what());
- return MU_ERROR;
+ /* note: user-level error, "OK" for mu */
+ report_error(er);
+ g_warning ("server caught exception: %s", er.what());
+ return MU_OK;
} catch (...) {
g_critical ("server caught exception");
g_set_error(err, MU_ERROR_DOMAIN, MU_ERROR, "%s", "caught exception");