Difference between revisions of "coroutine.resume"
(Created page with "Usually, errors that occur inside a coroutine do not get reported, which can lead to all sorts of coding catastrophes. To fix, include the following code before any use of corout...") |
(Added missing property for the category page; probably still useful, didn't check.) |
||
Line 14: | Line 14: | ||
[[Category:Snippets]] | [[Category:Snippets]] | ||
{{#set:Author=ccw}} | {{#set:Author=ccw}} | ||
+ | {{#set:LOVE Version=any}} | ||
{{#set:Description=Fix for hidden coroutine error messages.}} | {{#set:Description=Fix for hidden coroutine error messages.}} |
Latest revision as of 00:29, 12 November 2016
Usually, errors that occur inside a coroutine do not get reported, which can lead to all sorts of coding catastrophes. To fix, include the following code before any use of coroutine.resume
Source
_coroutine_resume = coroutine.resume
function coroutine.resume(...)
local state,result = _coroutine_resume(...)
if not state then
error( tostring(result), 2 ) -- Output error message
end
return state,result
end