errors and exceptions

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

errors and exceptions

fschmidt
Administrator
In Lua, one can throw any type as an error.  If you throw a string, Lua adds some stack info.  In Luan, whatever you throw becomes a message of an Exception and the Exception is thrown.  I don't like this because when you catch the exception in Luan, it is a Java object that you can't really access.  I don't like Lua's approach either.

I think the right approach is for an error to be a table.  The message would be in the table.  The stack trace would just be a list of stack trace elements in the table.  And the table would have a metatable containing __to_string to print out the whole error in a nice way.  Of course I would still throw an Exception internally, but the Exception would have a reference to the table and the table would have a reference to the exception.  Luan code would only see the table, but one could re-throw the table since it contains a reference to the exception.

I will do this tomorrow.
Woe to those who call bad good and good bad -- Isaiah 5:20
Following the Old Testament, not evil modern culture
Reply | Threaded
Open this post in threaded view
|

Re: errors and exceptions

fschmidt
Administrator
Implemented in rev 5d4a78c93383 and documented in rev 7e9fcfbf22ec.  You can close this.
Woe to those who call bad good and good bad -- Isaiah 5:20
Following the Old Testament, not evil modern culture
Reply | Threaded
Open this post in threaded view
|

Re: errors and exceptions

Hugo <Nabble>
It looks good. Closing thread.