Refactor exceptions in libdhcp-cc library
I have a use case related to #2408 (closed), where I intend to modify the control results returned by the lease_cmds
hook library. The #2408 (closed) introduces the conflict status code returned when the new or updated lease is in conflict with the server's configuration. However, there is also another class of errors that could be distinguished - errors returned for bad arguments. Hook libraries make use of the Kea parsers that generally throw DhcpConfigError
. The lease_cmds
hook can also throw BadValue
or InvalidParameter
. They all can mean similar things. We could use DhcpConfigError
everywhere, but its comment says it is to be removed in favor or the ConfigError
exception. I also think that DhcpConfigError
shouldn't be used for the commands that do not attempt to modify the configuration. There are tons of commands that only read the data but can still trigger the DhcpConfigError
. Overall, our use of the exceptions and the hierarchy makes it quite hard to differentiate between various error conditions.
In my opinion, we should have a BadCommandArguments
type of exception returned by the DHCP parsers. The hook libraries like lease_cmds
could also internally throw this error. Finally, when catching this exception, we could return a dedicated status code in the command response.