mod_admin_telnet: Use tostring as fallback in pretty printing
authorKim Alvefur <zash@zash.se>
Sat, 02 May 2020 20:41:35 +0200
changeset 10802 b81f4fd7f21a
parent 10801 1c61ef6a15ab
child 10803 763bb2ce3f60
mod_admin_telnet: Use tostring as fallback in pretty printing This has some nice effects such as functions, VirtualHosts and other things being printed using their `__tostring` metamethod.
plugins/mod_admin_telnet.lua
--- a/plugins/mod_admin_telnet.lua	Sat May 02 20:39:33 2020 +0200
+++ b/plugins/mod_admin_telnet.lua	Sat May 02 20:41:35 2020 +0200
@@ -335,6 +335,10 @@
 	if type(opts) ~= "table" then
 		opts = { preset = opts };
 	end
+	if not opts.fallback then
+		-- XXX Error message passed to fallback is lost, does it matter?
+		opts.fallback = tostring;
+	end
 	for k,v in pairs(serialize_defaults) do
 		if opts[k] == nil then
 			opts[k] = v;