get debug info

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

get debug info

Max Ischenko
I have the following piece of code:

local handler = function(errstr)
	Log(LOG_ALERT, errstr)
end
local code, msg = call(dispatch_command, 
	{commands, cmd}, 'x', handler)


When error occurs I get output like this:
attempt to index field `user' (a nil value)


Can I retrieve in what chunk (file) and in what line did error occurs?

-- 
Q. How many Mac programmers does it take to change a lightbulb?
A. None. You need a mouse to pull it down.

Reply | Threaded
Open this post in threaded view
|

Re: get debug info

Luiz Henrique de Figueiredo
>Can I retrieve in what chunk (file) and in what line did error occurs?

Try getinfo(2) in handler.
(2 works when an error occurs "naturally", but it should be 3 if you call
"error".)

--lhf

Reply | Threaded
Open this post in threaded view
|

Re: get debug info

Max Ischenko
Luiz Henrique de Figueiredo wrote:

> >Can I retrieve in what chunk (file) and in what line did error occurs?
> 
> Try getinfo(2) in handler.
> (2 works when an error occurs "naturally", but it should be 3 if you call
> "error".)

Thanks, it helps.

-- 
Best regards, Maxim F. Ischenko.