|
23 | 23 | from collections.abc import Callable
|
24 | 24 | from mkdocs.config.config_options import Plugins
|
25 | 25 | from mkdocs.config.defaults import MkDocsConfig
|
| 26 | +from mkdocs.exceptions import PluginError |
26 | 27 | from mkdocs.plugins import BasePlugin, event_priority
|
27 | 28 |
|
28 | 29 | from .config import GroupConfig
|
@@ -65,8 +66,14 @@ def on_config(self, config):
|
65 | 66 |
|
66 | 67 | # Load all plugins in group
|
67 | 68 | self.plugins: dict[str, BasePlugin] = {}
|
68 |
| - for name, plugin in self._load(option): |
69 |
| - self.plugins[name] = plugin |
| 69 | + try: |
| 70 | + for name, plugin in self._load(option): |
| 71 | + self.plugins[name] = plugin |
| 72 | + |
| 73 | + # The plugin could not be loaded, likely because it's not installed or |
| 74 | + # misconfigured, so we raise a plugin error for a nicer error message |
| 75 | + except Exception as e: |
| 76 | + raise PluginError(str(e)) |
70 | 77 |
|
71 | 78 | # Patch order of plugin methods
|
72 | 79 | for events in option.plugins.events.values():
|
@@ -99,9 +106,9 @@ def _load(self, option: Plugins):
|
99 | 106 |
|
100 | 107 | # -------------------------------------------------------------------------
|
101 | 108 |
|
102 |
| - # Patch order of plugin events - all other plugin methods are already in the |
103 |
| - # right order, so we only need to check those that are part of the group and |
104 |
| - # bubble them up into the right location. Some plugin methods may define |
| 109 | + # Patch order of plugin methods - all other plugin methods are already in |
| 110 | + # the right order, so we only need to check those that are part of the group |
| 111 | + # and bubble them up into the right location. Some plugin methods may define |
105 | 112 | # priorities, so we need to make sure to order correctly within those.
|
106 | 113 | def _patch(self, methods: list[Callable], config: MkDocsConfig):
|
107 | 114 | position = self._get_position(self, config)
|
|
0 commit comments