lua-users home
lua-l archive

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

On 2/16/06, LEGO <> wrote:
AFAIK you can do ADA's like error handling in lua.

function fly(from,to)
   --- ...
    error("motor blown")
   --- ...
    error("radio failure")
   --- ...
    error("sabotage occurred")

The problem with string error messages can be pointed at in your own example: 

   elseif problem == "radiu failure"

Numeric error codes (or other "fixed" types like an exception) are much more useful for error handling in code.  The strings are good for the end user for sure but code needs a little more.

This is especially true when dealing with multiple languages like I am.  I have a Lua backend interfacing to C, XML-RPC, and _javascript_.  The text messages are just not reliable enough with all these systems in play (versus numeric codes which would be easy to deal with in all those systems).

// Chris