diff --git a/src/Lib/Script/LuaContext.cc b/src/Lib/Script/LuaContext.cc index bc298d9c3d398fd7aa5750945baba42860fa6f73..0b15a53970878a13ae595bf3cbe877d26cd00221 100644 --- a/src/Lib/Script/LuaContext.cc +++ b/src/Lib/Script/LuaContext.cc @@ -78,7 +78,7 @@ LuaContext::Code LuaContext::exec() noexcept { if (lua_pcall(L, 0, 0, 0) != LUA_OK) { - err(this) << getLastError().toStdString().c_str() << "\n"; + err(this) << getLastLuaError().toStdString().c_str() << "\n"; return Code::Error; } return Code::Success; @@ -88,7 +88,7 @@ LuaContext::Code LuaContext::loadString(const char *str) noexcept { if (luaL_loadstring(L, str) != LUA_OK) { - err(this) << "Error loading string: " << getLastError().toStdString() << "\n"; + err(this) << "Error loading string: " << getLastLuaError().toStdString() << "\n"; return Code::Error; } return exec(); @@ -99,7 +99,8 @@ LuaContext::loadFile(const char *file) noexcept { currentFile = file; if (luaL_loadfile(L, file) != LUA_OK) { - err(this) << "Error loading file " << file << ": " << getLastError().toStdString() << "\n"; + err(this) + << "Error loading file " << file << ": " << getLastLuaError().toStdString() << "\n"; currentFile = ""; return Code::Error; } @@ -109,7 +110,7 @@ LuaContext::loadFile(const char *file) noexcept } QString -LuaContext::getLastError() noexcept +LuaContext::getLastLuaError() noexcept { const char *error = lua_tostring(L, -1); QString ret = QString("%1").arg(error); diff --git a/src/Lib/Script/LuaContext.hh b/src/Lib/Script/LuaContext.hh index 2e165626d35456dc8a8ba34d10b2e5f1f65a6ec0..63abb7ca354388f1f332afb92e0c5181defb6169 100644 --- a/src/Lib/Script/LuaContext.hh +++ b/src/Lib/Script/LuaContext.hh @@ -41,7 +41,7 @@ public: ~LuaContext() noexcept; Code loadDocument(std::shared_ptr<ScriptDocument>) noexcept; - QString getLastError() noexcept; + QString getLastLuaError() noexcept; lua_State *getState() noexcept; auto &getOutputStream() noexcept { return streamOut; } @@ -59,6 +59,8 @@ public: const ModuleDeclaration *getModule(const std::string_view) const noexcept; const std::vector<std::string_view> getAllModuleName() const noexcept; + // Some verifications gone wrong, this is not a Lua error, this is a script + // runtime error. void setFailed(const std::string &) noexcept; bool isFailed() const noexcept; const std::string &getFailureDescription() const noexcept; diff --git a/src/Lib/Script/ScriptStore.cc b/src/Lib/Script/ScriptStore.cc index ad8e16e5047977d5bbfa8ed31ac2cbfb5206c044..6a0d6f8f6263832e1dcfb0ef0aae342e90072301 100644 --- a/src/Lib/Script/ScriptStore.cc +++ b/src/Lib/Script/ScriptStore.cc @@ -19,7 +19,7 @@ ScriptStore::loadScriptFolder(const QString &folderPath) if (luaContext->loadDocument(doc) != Script::LuaContext::Code::Success) { const QString error = QStringLiteral("File: ") + file + QStringLiteral(" [") + doc->getUuid().toString() + QStringLiteral("]") + - luaContext->getLastError(); + luaContext->getLastLuaError(); throw std::runtime_error(error.toStdString()); } } diff --git a/src/Lib/Utils.hh b/src/Lib/Utils.hh index 8c5a483b334ecaf3016242d4f567c6883bf81e3c..bf61eedb9d13e2ee85a8d33e90f766b8c4e9b1bc 100644 --- a/src/Lib/Utils.hh +++ b/src/Lib/Utils.hh @@ -53,7 +53,7 @@ static const QStringList audioFileSuffix = { "wave", "wav", "ogg", "mp3", "m4 static const QStringList videoFileSuffix = { "mkv", "mp4", "mov", "avi", "av1", "m4v", "flv" }; static const QStringList assFileSuffix = { "ass" }; static const QStringList vivyFileSuffix = { "vivy" }; -static const QStringList scriptFileSuffix = { "lua", "vvs" }; +static const QStringList scriptFileSuffix = { "module" }; const QString &getAudioFileSuffixFilter() noexcept; const QString &getVideoFileSuffixFilter() noexcept;