summaryrefslogtreecommitdiffstats
path: root/pkgs
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-11-17 14:18:24 +0000
committertv <tv@krebsco.de>2026-11-17 15:19:22 +0100
commit9d78b7f285362174e7540c4c035a62ba58d742df (patch)
tree03e2e722f5b905298e1caffdb63f4c996d10a8dd /pkgs
parent2d18a83323be0e26451ac8b99f03bcbb68c2012e (diff)
cgit-about-filter: show errors
While a Lua filter is open, cgit hooks its own output into the filter. On a Lua error, cgit's error page ends up in the filter's buffer, so the response ends after <div id='summary'> and nothing is logged. Catch errors in filter_close and show them with a traceback.
Diffstat (limited to 'pkgs')
-rw-r--r--pkgs/simple/cgit-about-filter/cgit-about-filter.lua14
1 files changed, 13 insertions, 1 deletions
diff --git a/pkgs/simple/cgit-about-filter/cgit-about-filter.lua b/pkgs/simple/cgit-about-filter/cgit-about-filter.lua
index 8bab6b6..3bbbbcf 100644
--- a/pkgs/simple/cgit-about-filter/cgit-about-filter.lua
+++ b/pkgs/simple/cgit-about-filter/cgit-about-filter.lua
@@ -312,7 +312,7 @@ function filter_write(str)
end
end
-function filter_close()
+local function close()
if not should_render then
emit("<p><em>Error: Access Denied. Only README.md and documentation markdown files are viewable here.</em></p>")
return
@@ -386,3 +386,15 @@ function filter_close()
emit("<p>Error: Could not execute md2html.</p>")
end
end
+
+-- cgit hooks its output into the filter while the filter is open, so the
+-- error page of a Lua error in here would end up in the buffer, and the
+-- response would end without a word. Show the error instead.
+function filter_close()
+ local ok, err = xpcall(close, debug.traceback)
+ if not ok then
+ emit("<pre>")
+ ;(html_txt or io.write)(err)
+ emit("</pre>")
+ end
+end