diff irccdctl/cli.cpp @ 543:7051034bf2ee

Irccdctl: abort in case of error
author David Demelier <markand@malikania.fr>
date Tue, 21 Nov 2017 13:40:39 +0100
parents 80c3caafe9d3
children 1ef194b6b168
line wrap: on
line diff
--- a/irccdctl/cli.cpp	Tue Nov 21 12:29:50 2017 +0100
+++ b/irccdctl/cli.cpp	Tue Nov 21 13:40:39 2017 +0100
@@ -37,6 +37,11 @@
         if (code)
             throw boost::system::system_error(code);
 
+        if (message["error"].is_number_integer())
+            throw boost::system::system_error(static_cast<network_errc>(message["error"].template get<int>()));
+        if (message["error"].is_string())
+            throw std::runtime_error(message["error"].template get<std::string>());
+
         auto c = json_util::to_string(message["command"]);
 
         if (c != req["command"].get<std::string>()) {
@@ -44,11 +49,6 @@
             return;
         }
 
-        if (message["error"].is_number_integer())
-            throw boost::system::system_error(static_cast<network_errc>(message["error"].template get<int>()));
-        if (message["error"].is_string())
-            throw std::runtime_error(message["error"].template get<std::string>());
-
         if (handler)
             handler(std::move(message));
     });