diff options
| -rw-r--r-- | pkgs/simple/cgit-about-filter/cgit-about-filter.lua | 14 |
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 |
