[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Exceptions (was Re: Custom extensions to Lua)
- From: Adrian Sietsma <adrian_groups@...>
- Date: Sat, 13 Aug 2005 18:06:57 +1000
Luiz Henrique de Figueiredo wrote:
I think part of the issue is that Lua has a couple of methods for reporting
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
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.