lua-users home
lua-l archive

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


one way to print errors, but avoid the abortion is to use Lua's error () function together with pcall (). pcall () catches the error and returns the message.
Maybe the assert() function could also be helpful to you.

Further I found this presentation from John Belmonte about exception patterns in Lua:

Maybe this helps :-)
Kind regards,

Thomas Daldier wrote:
Hello, I'm a bit (a lot bit) new to binding C/C++ with Lua (I've only been doing this for about a week), and I would like a bit of help on Lua error handling:

I've been working on a game engine in C++, and I want Lua to print every error it comes across. The only way I can get an error message (it seems) is if Lua comes across a fatal error that causes Lua to abort the script completely.
What is the best way to print Lua errors?

I've searched on Google and in the documentation, but I can't seem to find exactly what I'm looking for.

If somebody could give me a simple example or link me to something that shows me how to do this, that would be nice.

Thanks, Sgt. Sparky.

Store, manage and share up to 5GB with Windows Live SkyDrive. Start uploading now <>