From 8a3a125ca37c3f2920b5d77200bb557e25d01f66 Mon Sep 17 00:00:00 2001 From: "Dirk-Jan C. Binnema" Date: Sat, 31 Jul 2021 01:48:24 +0300 Subject: [PATCH] mu-cmd-server: report errors to mu4e Even "existential errors" that cause mu-server not to start. --- mu/mu-cmd-server.cc | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/mu/mu-cmd-server.cc b/mu/mu-cmd-server.cc index 82c6095e..61857318 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(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");