diff --git a/moonscript/init.lua b/moonscript/init.lua index 2488d6d..deb1a8c 100644 --- a/moonscript/init.lua +++ b/moonscript/init.lua @@ -56,10 +56,13 @@ moon_loader = function(name) if file then local text = file:read("*a") file:close() - return loadstring(text, file_path) - else - return nil, "Could not find moon file" + local res, err = loadstring(text, file_path) + if not res then + error(err) + end + return res end + return nil, "Could not find moon file" end if not package.moonpath then package.moonpath = create_moonpath(package.path) diff --git a/moonscript/init.moon b/moonscript/init.moon index 2c9fe41..977c63b 100644 --- a/moonscript/init.moon +++ b/moonscript/init.moon @@ -47,9 +47,13 @@ moon_loader = (name) -> if file text = file\read "*a" file\close! - loadstring text, file_path - else - nil, "Could not find moon file" + res, err = loadstring text, file_path + if not res + error err + + return res + + return nil, "Could not find moon file" if not package.moonpath package.moonpath = create_moonpath package.path