Mercurial > irccd
changeset 612:420480ce53e0
Irccdctl: use category string instead of ints
author | David Demelier <markand@malikania.fr> |
---|---|
date | Fri, 15 Dec 2017 16:35:49 +0100 |
parents | 9fbd1700435b |
children | 0c7241258289 |
files | libirccdctl/irccd/ctl/controller.cpp |
diffstat | 1 files changed, 5 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/libirccdctl/irccd/ctl/controller.cpp Fri Dec 15 15:37:58 2017 +0100 +++ b/libirccdctl/irccd/ctl/controller.cpp Fri Dec 15 16:35:49 2017 +0100 @@ -90,7 +90,6 @@ assert(handler); // TODO: ensure connected. - conn_.recv([handler] (auto code, auto msg) { if (code) { handler(std::move(code), std::move(msg)); @@ -98,15 +97,15 @@ } auto e = json_util::to_int(msg["error"]); + auto c = json_util::to_string(msg["errorCategory"]); - // TODO: maybe better to pass category instead of using static ranges. - if (e > 0 && e < 1000) + if (c == "irccd") code = make_error_code(static_cast<irccd_error::error>(e)); - else if (e >= 1000 && e < 2000) + else if (c == "server") code = make_error_code(static_cast<server_error::error>(e)); - else if (e >= 2000 && e < 3000) + else if (c == "plugin") code = make_error_code(static_cast<plugin_error::error>(e)); - else if (e >= 4000 && e < 5000) + else if (c == "rule") code = make_error_code(static_cast<rule_error::error>(e)); handler(std::move(code), std::move(msg)); @@ -118,7 +117,6 @@ assert(message.is_object()); // TODO: ensure connected. - conn_.send(std::move(message), std::move(handler)); }