[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: loadfile and line number
- From: Luiz Henrique de Figueiredo <lhf@...>
- Date: Thu, 11 Oct 2012 08:17:37 -0300
> When loadfile() or loadstring() fail they return (nil, message). The
> message contains the line number where the error occurred. How the
> script can obtain that line number not resorting to parsing the message
> string?
It can't, sorry. The line number is added to the error message deep down
in the Lua core:
http://www.lua.org/source/5.2/llex.c.html#lexerror
You can extract the line number from the error message with
string.match(message,":(%d+):")