[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- 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
Hi,
On Wed, Aug 20, 2008 at 2:07 AM, E. Wing <ewmailing@gmail.com> 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
> data?
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_pushvalue(L, -2);
lua_pushliteral(L, ":(%d+):");
lua_call(L, 2, 1);
// Do something with the line number...
}
Cheers,
--
-Patrick Donnelly
"One of the lessons of history is that nothing is often a good thing
to do and always a clever thing to say."
-Will Durant