lua-users home
lua-l archive

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


Luiz Henrique de Figueiredo wrote:
I think part of the issue is that Lua has a couple of methods for reporting
errors:


Sure, but they serve different purposes. Throwing an error is meant for
hard errors, things that should not occur and the programmer doesn't
what to handle. Returning nil+message is meant for soft errors, things
that may occur and that the programmer wants to handle. Or am I missing
something? --lhf


i have split the 2 cases in my coroutine depatcher -

asserts and lua errors are caught by the scheduler and call a custom error handler - default behavior is to stop the scheduler and return nil, error

try/catch is used for per-thread errors; default behaviour is to print error message and kill thread but not scheduler.

ie (from any thread)

assert(nil,"hard error") will stop the scheduler and return nil,"hard error"

try(nil,"soft error") will print(thread,"soft error") and kill the thread, but keep the scheduler loop running.

both error and catch handler can be overridden.

Adrian