lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


I am writing a small program that uses the method of PiL Chapter 10.1
of reading a "configuration" file.  That is, define a bunch of
functions and that dofile() the config file that calls them.  Great
stuff, I love it.

Now, my question is about error reporting.  I am using assert()
liberally, and for technical error reporting that is excellent.  But
now I am facing the prospect of other people using this and would like
to get error messages that give the file name of the config file and
line number therein where the error occurred.

So, if I have something like

function foo()
	assert(nil, "an error")


And the file conf just says "foo{}", then I'd like to get an error

.../conf:1: an error

instead of

.../main.lua:3: an error

Is there an easy way to do this?