metis.exception
Utilities for working with errors and exceptions.
rethrow(message, context) | Rethrow an exception that occurred within a child coroutine. |
---|
- rethrow(message, context)Source
Rethrow an exception that occurred within a child coroutine.
This integrates with CC:T's exception protocol, to ensure friendlier error reporting in the shell. This
Parameters
- message The error message.
- context
coroutine
The thread executing this code.
Usage
Define a function
checked_resume
, which attempts to resume a coroutine, and rethrows any errors usingrethrow
.local rethrow = require "metis.exception".rethrow local function checked_resume(co, ...) local ok, result = coroutine.resume(co, ...) if not ok then rethrow(co, result) end return result end