]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#549] not strictly related: better command errors
authorAndrei Pavel <andrei@isc.org>
Wed, 5 Apr 2023 13:10:24 +0000 (16:10 +0300)
committerAndrei Pavel <andrei@isc.org>
Wed, 19 Apr 2023 20:56:01 +0000 (23:56 +0300)
The command errors were not very accurate. Some contained technical
terms like Element which are not suited for administrators.

src/lib/cc/command_interpreter.cc

index 4d1820b044e2432150404c7531d5788509783707..26574cd35279dc4159dfc636229e5659b290ad97 100644 (file)
@@ -173,11 +173,12 @@ parseCommand(ConstElementPtr& arg, ConstElementPtr command) {
         isc_throw(CtrlChannelError, "No command specified");
     }
     if (command->getType() != Element::map) {
-        isc_throw(CtrlChannelError, "Invalid command Element specified, expected map");
+        isc_throw(CtrlChannelError, "invalid command: expected toplevel entry to be a map, got "
+                                        << Element::typeToName(command->getType()) << " instead");
     }
     if (!command->contains(CONTROL_COMMAND)) {
         isc_throw(CtrlChannelError,
-                  "Invalid answer specified, does not contain mandatory 'command'");
+                  "invalid command: does not contain mandatory '" << CONTROL_COMMAND << "'");
     }
 
     // Make sure that all specified parameters are supported.
@@ -187,15 +188,16 @@ parseCommand(ConstElementPtr& arg, ConstElementPtr command) {
             (param.first != CONTROL_ARGUMENTS) &&
             (param.first != CONTROL_SERVICE) &&
             (param.first != CONTROL_REMOTE_ADDRESS)) {
-            isc_throw(CtrlChannelError, "Received command contains unsupported "
-                      "parameter '" << param.first << "'");
+            isc_throw(CtrlChannelError,
+                      "invalid command: unsupported parameter '" << param.first << "'");
         }
     }
 
     ConstElementPtr cmd = command->get(CONTROL_COMMAND);
     if (cmd->getType() != Element::string) {
-        isc_throw(CtrlChannelError,
-                  "'command' element in command message is not a string");
+        isc_throw(CtrlChannelError, "invalid command: expected '"
+                                        << CONTROL_COMMAND << "' to be a string, got "
+                                        << Element::typeToName(command->getType()) << " instead");
     }
 
     arg = command->get(CONTROL_ARGUMENTS);