From 07327c2b6548777330a877ee1cd0e33a1b42ddb5 Mon Sep 17 00:00:00 2001 From: Thomas Goyne Date: Tue, 7 Feb 2012 23:17:06 +0000 Subject: [PATCH] Add position information to the error message when aegisub.log is called with bad arguments Originally committed to SVN as r6455. --- aegisub/src/auto4_lua_progresssink.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/aegisub/src/auto4_lua_progresssink.cpp b/aegisub/src/auto4_lua_progresssink.cpp index d8aee827e..a9b9c48a7 100644 --- a/aegisub/src/auto4_lua_progresssink.cpp +++ b/aegisub/src/auto4_lua_progresssink.cpp @@ -42,6 +42,7 @@ #ifdef __WINDOWS__ #include "../../contrib/lua51/src/lua.h" +#include "../../contrib/lua51/src/lauxlib.h" #else #include #endif @@ -165,7 +166,14 @@ namespace Automation4 { // put the format function into place lua_insert(L, 1); // call format function - lua_call(L, lua_gettop(L)-1, 1); + if (lua_pcall(L, lua_gettop(L) - 1, 1, 0)) { + // format failed so top of the stack now has an error message + // which we want to add position information to + luaL_where(L, 1); + lua_insert(L, 1); + lua_concat(L, 2); + lua_error(L); + } } // Top of stack is now a string to output