aboutsummaryrefslogtreecommitdiff
path: root/manual
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2019-06-05 13:16:25 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2019-06-05 13:16:25 -0300
commitb4d5dff8ec4f1c8a44db66d368e95d359b04aea7 (patch)
treee87fbd3bcbf8a271429ee31f32eaf928058ab376 /manual
parent14edd364c3abcb758e74c68a2bdd4ddaeefdae2a (diff)
downloadlua-b4d5dff8ec4f1c8a44db66d368e95d359b04aea7.tar.gz
lua-b4d5dff8ec4f1c8a44db66d368e95d359b04aea7.tar.bz2
lua-b4d5dff8ec4f1c8a44db66d368e95d359b04aea7.zip
Multiple errors in '__toclose' report the first one
When there are multiple errors when closing objects, the error reported by the protected call is the first one, for two reasons: First, other errors may be caused by this one; second, the first error is handled in the original execution context, and therefore has the full traceback.
Diffstat (limited to 'manual')
-rw-r--r--manual/manual.of21
1 files changed, 15 insertions, 6 deletions
diff --git a/manual/manual.of b/manual/manual.of
index 4c9c20b2..2c0957b9 100644
--- a/manual/manual.of
+++ b/manual/manual.of
@@ -1541,11 +1541,17 @@ if there was no error, the second argument is @nil.
1541 1541
1542If several to-be-closed variables go out of scope at the same event, 1542If several to-be-closed variables go out of scope at the same event,
1543they are closed in the reverse order that they were declared. 1543they are closed in the reverse order that they were declared.
1544
1544If there is any error while running a closing method, 1545If there is any error while running a closing method,
1545that error is handled like an error in the regular code 1546that error is handled like an error in the regular code
1546where the variable was defined; 1547where the variable was defined;
1547in particular, 1548in particular,
1548the other pending closing methods will still be called. 1549the other pending closing methods will still be called.
1550After an error,
1551other errors in closing methods
1552interrupt the respective method,
1553but are otherwise ignored;
1554the error reported is the original one.
1549 1555
1550If a coroutine yields inside a block and is never resumed again, 1556If a coroutine yields inside a block and is never resumed again,
1551the variables visible at that block will never go out of scope, 1557the variables visible at that block will never go out of scope,
@@ -1553,11 +1559,12 @@ and therefore they will never be closed.
1553Similarly, if a coroutine ends with an error, 1559Similarly, if a coroutine ends with an error,
1554it does not unwind its stack, 1560it does not unwind its stack,
1555so it does not close any variable. 1561so it does not close any variable.
1556You should either use finalizers 1562In both cases,
1557or call @Lid{coroutine.close} to close the variables in these cases. 1563you should either use finalizers
1558However, note that if the coroutine was created 1564or call @Lid{coroutine.close} to close the variables.
1565However, if the coroutine was created
1559through @Lid{coroutine.wrap}, 1566through @Lid{coroutine.wrap},
1560then its corresponding function will close all variables 1567then its corresponding function will close the coroutine
1561in case of errors. 1568in case of errors.
1562 1569
1563} 1570}
@@ -3932,7 +3939,7 @@ Returns a status code:
3932@Lid{LUA_OK} for no errors in closing methods, 3939@Lid{LUA_OK} for no errors in closing methods,
3933or an error status otherwise. 3940or an error status otherwise.
3934In case of error, 3941In case of error,
3935leave the error object on the stack, 3942leaves the error object on the top of the stack,
3936 3943
3937} 3944}
3938 3945
@@ -6355,6 +6362,7 @@ Closes coroutine @id{co},
6355that is, 6362that is,
6356closes all its pending to-be-closed variables 6363closes all its pending to-be-closed variables
6357and puts the coroutine in a dead state. 6364and puts the coroutine in a dead state.
6365The given coroutine must be dead or suspended.
6358In case of error closing some variable, 6366In case of error closing some variable,
6359returns @false plus the error object; 6367returns @false plus the error object;
6360otherwise returns @true. 6368otherwise returns @true.
@@ -6412,7 +6420,8 @@ true when the running coroutine is the main one.
6412 6420
6413Returns the status of the coroutine @id{co}, as a string: 6421Returns the status of the coroutine @id{co}, as a string:
6414@T{"running"}, 6422@T{"running"},
6415if the coroutine is running (that is, it called @id{status}); 6423if the coroutine is running
6424(that is, it is the one that called @id{status});
6416@T{"suspended"}, if the coroutine is suspended in a call to @id{yield}, 6425@T{"suspended"}, if the coroutine is suspended in a call to @id{yield},
6417or if it has not started running yet; 6426or if it has not started running yet;
6418@T{"normal"} if the coroutine is active but not running 6427@T{"normal"} if the coroutine is active but not running