check_handlers/1 crashes with undef when a handler's command module is missing #6
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Purpose (fix):
evoq_command_handler:check_handlers/1names a handler whose command module is missing, instead of crashing withundef.Refs reckon-db-org/evoq#3
The defect
check_handlers/1(forge PR 5) loads each handler and reads its behaviour attributes. It then calls(Handler:command_module()):command_type(). When that command module cannot be loaded (renamed, deleted, mistyped), the call raisesundefand does not return a named problem. A service's test still fails, but on a crash that names nothing, where{not_loadable, ...}or{wrong_command_type, ...}would name the desk.Found by Uranus in the review of PR 5 (a note, not a FAIL).
Fix shape
Check the command module like the handler:
code:ensure_loaded/1first. If it fails, answer{command_module_not_loadable, CommandType, Handler, CommandModule, Reason}and add it tohandler_problem(). Add one test for it, and a mutant on the new clause.Done when
command_module/0names an unloadable module makescheck_handlers/1return{error, [{command_module_not_loadable, ...}]}, with no crash