Pi66

merodi
A markdown-based static site generator.
git clone https://git.pi66.xyz/merodi

← back to log

fix: handle plugin loading failures

author: pi66
date: 2026-06-29 16:41
hash: 51699c04869d23eeb6d5260e47d64c27a8bae1fd

Diffstat:

M

src/build.py
22 ++++++++++++++++++------------
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
diff --git a/src/build.py b/src/build.py
index 16bffa4..158cd76 100644
--- a/src/build.py
+++ b/src/build.py
@@ -26,15 +26,19 @@ replace_filters = [
 ]

 def load_plugins(path):
-    spec = importlib.util.spec_from_file_location("plugins", path)
-    module = importlib.util.module_from_spec(spec)
-    spec.loader.exec_module(module)
-
-    return {
-        name: value
-        for name, value in vars(module).items()
-        if not name.startswith("_")
-    }
+    try:
+        spec = importlib.util.spec_from_file_location("plugins", path)
+        module = importlib.util.module_from_spec(spec)
+        spec.loader.exec_module(module)
+
+        return {
+            name: value
+            for name, value in vars(module).items()
+            if not name.startswith("_")
+        }
+
+    except Exception as e:
+        raise RuntimeError(f"Failed loading plugin {path}: {e}") from e


 def html_filter(html_content:str):