diff --git a/src/model/project/project.lua b/src/model/project/project.lua index 9d4a0777..13114d85 100644 --- a/src/model/project/project.lua +++ b/src/model/project/project.lua @@ -382,7 +382,11 @@ function ProjectService:run(name, env) p_path, err = self.is_project(ProjectService.path, name) end if p_path then - local _, code = self.current:readfile(ProjectService.MAIN) + local ok, code = self.current:readfile(ProjectService.MAIN) + if not ok then return nil, code, p_path end + if type(code) ~= 'string' then + return nil, FS.messages.unreadable(ProjectService.MAIN), p_path + end local content, c_err = codeload(code, env) return content, c_err, p_path end diff --git a/src/util/lua.lua b/src/util/lua.lua index 299ff7a4..beca8068 100644 --- a/src/util/lua.lua +++ b/src/util/lua.lua @@ -14,6 +14,9 @@ end --- @return function? chunk --- @return string? err local codeload = function(code, env) + if type(code) ~= 'string' then + return nil, ('code must be a string (got %s)'):format(type(code)) + end local f, err = loadstring(code) if not f then return nil, err end