[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Error handling
- From: Chris <coderight@...>
- Date: Thu, 16 Feb 2006 15:29:40 -0500
What is the proper way to do real error handling in Lua?
Currently I see the error(msg) call and checking return values from functions.
error() is too limited because you can not programmatically tell what
happened. All you can return is a string. This is fine for
interactive stuff but not so good when you need your program to take
special actions when certain errors occur
The only other choice I know of is to return error codes from every
function. This is extremely annoying and almost destroys the
point of using a scripting language in the first place. Then you
start having to worry about both returned error codes and catching
errors returned via error() and makes the code ugly.
I'm thinking what would be nice is if error() (and the C versions like
lua_error) could return more than just a text message. Or some
sort of exception mechanism. Or... Is anything like that possible?