From ced3dd7a7ef0ef04bdc080edb502a44931ad0c24 Mon Sep 17 00:00:00 2001 From: Thomas Goyne Date: Sat, 21 Sep 2013 12:10:37 -0700 Subject: [PATCH] Improve error reporting when an automation script fails to load Cut down on the amount of redundant information displayed so that the actual error is visible. --- aegisub/src/auto4_base.cpp | 2 +- aegisub/src/auto4_lua.cpp | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/aegisub/src/auto4_base.cpp b/aegisub/src/auto4_base.cpp index 1af73472d..6422b86e0 100644 --- a/aegisub/src/auto4_base.cpp +++ b/aegisub/src/auto4_base.cpp @@ -474,7 +474,7 @@ namespace Automation4 { auto s = factory->Produce(filename); if (s) { if (!s->GetLoadedState()) { - wxLogError(_("An Automation script failed to load. File name: '%s', error reported: %s"), filename.wstring(), s->GetDescription()); + wxLogError(_("Failed to load Automation script '%s':\n%s"), filename.wstring(), s->GetDescription()); } return s; } diff --git a/aegisub/src/auto4_lua.cpp b/aegisub/src/auto4_lua.cpp index aa52a059a..b5f76fbe6 100644 --- a/aegisub/src/auto4_lua.cpp +++ b/aegisub/src/auto4_lua.cpp @@ -438,7 +438,7 @@ namespace Automation4 { // load user script if (!LoadFile(L, GetFilename())) { - std::string err = str(boost::format("Error loading Lua script \"%s\":\n\n%s") % GetPrettyFilename().string() % get_string_or_default(L, 1)); + std::string err = get_string_or_default(L, 1); lua_pop(L, 1); throw ScriptLoadError(err); } @@ -558,7 +558,7 @@ namespace Automation4 { try { if (!LoadFile(L, path)) - return luaL_error(L, "Error loading Lua module \"%s\":\n\n%s", path.string().c_str(), luaL_checkstring(L, 1)); + return luaL_error(L, "Error loading Lua module \"%s\":\n%s", path.string().c_str(), luaL_checkstring(L, 1)); break; } catch (agi::fs::FileNotFound const&) { @@ -568,7 +568,7 @@ namespace Automation4 { // Not an error so swallow and continue on } catch (agi::Exception const& e) { - return luaL_error(L, "Error loading Lua module \"%s\":\n\n%s", path.string().c_str(), e.GetChainedMessage().c_str()); + return luaL_error(L, "Error loading Lua module \"%s\":\n%s", path.string().c_str(), e.GetChainedMessage().c_str()); } } @@ -597,7 +597,7 @@ namespace Automation4 { return luaL_error(L, "Lua include not found: %s", filename.c_str()); if (!LoadFile(L, filepath)) - return luaL_error(L, "Error loading Lua include \"%s\":\n\n%s", filename.c_str(), luaL_checkstring(L, 1)); + return luaL_error(L, "Error loading Lua include \"%s\":\n%s", filename.c_str(), luaL_checkstring(L, 1)); int pretop = lua_gettop(L) - 1; // don't count the function value itself lua_call(L, 0, LUA_MULTRET);