Diff

util/pluginloader.lua @ 13829:dde0ce03049b 13.0

modulemanager, util.pluginloader: Improve error message when load fails but some candidates were filtered
author Matthew Wild <mwild1@gmail.com>
date Wed, 09 Apr 2025 10:53:37 +0100
parent 12975:d10957394a3c
line wrap: on
line diff
--- a/util/pluginloader.lua	Fri Apr 04 16:50:25 2025 +0100
+++ b/util/pluginloader.lua	Wed Apr 09 10:53:37 2025 +0100
@@ -25,6 +25,7 @@
 function pluginloader_methods:load_file(names)
 	local file, err, path;
 	local load_filter_cb = self._options.load_filter_cb;
+	local last_filter_path, last_filter_err;
 	for i=1,#plugin_dir do
 		for j=1,#names do
 			path = plugin_dir[i]..names[j];
@@ -36,12 +37,18 @@
 				if load_filter_cb then
 					path, content, metadata = load_filter_cb(path, content);
 				end
-				if content and path then
+				if path and content then
 					return content, path, metadata;
+				else
+					last_filter_path = plugin_dir[i]..names[j];
+					last_filter_err = content or "skipped";
 				end
 			end
 		end
 	end
+	if last_filter_err then
+		return nil, err..(" (%s skipped because of %s)"):format(last_filter_path, last_filter_err);
+	end
 	return file, err;
 end