[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Error handling
- From: Chris <coderight@...>
- Date: Thu, 16 Feb 2006 20:56:42 -0500
In case anyone was wondering, this is what I settled on:
function throw(code, msg)
local s,e,location = string.find(debug.traceback(), ".-\n.-\n(.-:.-):")
if not s then location = "Unknown:0" end
return {code,location,msg}
end
Then from in the code I use:
throw(code, "msg")
What comes out is a table:
err[1] is the code
err[2] is the location (filename:line)
err[3] is the message
You have to be careful with this though because if you don't use a
protected call you won't get any meaningful error message at all.
--
// Chris