From afc1d932798562d1bb2a6304da8733023c015268 Mon Sep 17 00:00:00 2001 From: Andrei Pavel Date: Wed, 5 Apr 2023 16:10:24 +0300 Subject: [PATCH] [#549] not strictly related: better command errors 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 | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/lib/cc/command_interpreter.cc b/src/lib/cc/command_interpreter.cc index 4d1820b044..26574cd352 100644 --- a/src/lib/cc/command_interpreter.cc +++ b/src/lib/cc/command_interpreter.cc @@ -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); -- 2.47.2