mod_rest/apidemo: Don't show traceback to users on config/resource problem
authorKim Alvefur <zash@zash.se>
Sun, 17 Apr 2022 12:52:13 +0200
changeset 4932 d5612dcf6733
parent 4931 77b7e1322281
child 4933 65438e4ba563
mod_rest/apidemo: Don't show traceback to users on config/resource problem
mod_rest/apidemo.lib.lua
--- a/mod_rest/apidemo.lib.lua	Sun Apr 17 12:51:45 2022 +0200
+++ b/mod_rest/apidemo.lib.lua	Sun Apr 17 12:52:13 2022 +0200
@@ -11,7 +11,12 @@
 	});
 
 local index do
-	local f = assert(io.open(api_demo.."/index.html"), "'rest_demo_resources' should point to the 'dist' directory");
+	local f, err = io.open(api_demo.."/index.html");
+	if not f then
+		module:log("error", "Could not open resource: %s", err);
+		module:log("error", "'rest_demo_resources' should point to the 'dist' directory");
+		return _M
+	end
 	index = f:read("*a");
 	f:close();