try
-finally
(tweet)
#4817
ggreif
started this conversation in
Show and tell
8000
`try`-`finally` (tweet)
#4817
Replies: 1 comment
-
Posted on twitter: https://x.com/DFINITYDev/status/1900481277649629622 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
The recent addition of
finally
-clauses totry
-blocks not only gives you a powerful tool to clean up (e.g. locks) in a disciplined and structured way. It will interpose all control-flow paths outward of thetry
-catch
and additionally also clean up if a canister traps after receiving a reply from extern. Previously this scenario could potentially brick your canister. Still, be very careful when reviewing code that does external messaging and may trap. Continue learning at https://internetcomputer.org/docs/current/motoko/main/writing-motoko/errors/#using-tryfinally.Beta Was this translation helpful? Give feedback.
All reactions