[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: How do I get the filename and line number from a failed luaL_loadfile?
- From: "Patrick Donnelly" <batrick.donnelly@...>
- Date: Wed, 20 Aug 2008 02:20:32 -0600
On Wed, Aug 20, 2008 at 2:07 AM, E. Wing <firstname.lastname@example.org> wrote:
> I want to get the filename (with absolute path) and line number
> reported from luaL_loadfile. Is there a reliable way to get at this
You have the (relative) file name/path; you passed it to
luaL_loadfile. Parsing the error message is your best option (afaik):
if (luaL_loadfile(L, "filepath") == LUA_ERRSYNTAX)
lua_getfield(L, -1, "match");
lua_call(L, 2, 1);
// Do something with the line number...
"One of the lessons of history is that nothing is often a good thing
to do and always a clever thing to say."