lua-users home
lua-l archive

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

On Tue, 21 Mar 2000, Luiz Henrique de Figueiredo wrote:
> But you cannot return to the point where the error occured and continue
> execution. (How would Lua continue?)

   What i'm thinking of is more along the lines of something like Java/C++
   exception handling:

     -- do something   
     -- if an error occurred
     -- always done

> Perhaps you could give examples of the complicated error handling you have
> in mind.

   Complicated may have been the wrong word to use. In general, it's
   desirable to be able to signal an error without completely stopping
   the current thread of execution. For instance, with an XML Parser, you
   might want to have a default structure generated when the XML file
   has an error.

   Basically, it quickly becomes tiresome(at least for me) to constantly
   check the return codes of functions for failure codes. Instead, having
   a exception wrapper makes life much easier. For instance, consider a
   SQL interface.  At any point during the process of a select(getting the
   connection, preparing the statement, executing the statement, grabbing
   the results, and closing the connection) you can have a SQL related
   error. It's much easier to have something like try/catch as an umbrella
   around this than to have an if after each call.

   I don't think Lua necessarily needs exception handling, but if there's
   some way to build a finer granularity of error handling, that would be
   quite helpful. For instance, perhaps the ability to have error only
   stop the execution of the current function, but leave the calling
   function running.