Added proper failing when a plugin is not loaded

This commit is contained in:
Pünkösd Marcell 2021-04-14 18:11:23 +02:00
parent 413e1e8a20
commit 5ffaa6228b

View File

@ -11,6 +11,10 @@ class UnknownPlugin(Exception):
pass
class UnknownCommand(Exception):
pass
class PluginRepository:
def __init__(self):
@ -67,7 +71,10 @@ class PluginRepository:
return list(self._command_compilers.keys())
def get_compiler(self, command: str) -> AbstractCommandCompiler:
return self._command_compilers[command]
try:
return self._command_compilers[command]
except KeyError:
raise UnknownCommand(f"Could not find compiler for command: {command}! A plugin might be not loaded.")
def get_plugin_instance(self, plugin: str) -> AbstractPlugin:
return self._loaded_plugins[plugin]