Closed ffried closed 12 months ago
@weissi I'm curious if you have an opinion on this?
FWIW, I have implemented similar methods before but the one difference is that I (and @weissi) have put the deferred closure into an unstructured task Task {}
. The reason for this is that often the code in the defer must run but if the task is already cancelled that code will also get cancelled. I haven't looked at the usages here but this might be an important thing to consider.
@FranzBusch That is a very good point! It this case, it does not make things worse (since the previous implementations actually suffered from the same problem), but it's still something worth having a look at.
With these new helper functions, we can at least change it in a central place (vs. having to adjust multiple sites that follow this pattern).
@swift-ci test
@swift-ci test
This offers a more generalized solution to the bugs fixed in #55 and #56 by adding a
Helpers
target that (currently) containswithThrowingDefer
andwithAsyncThrowingDefer
.Those functions basically do what was previously done manually at each such occasion:
work
closuredeferred
closure no matter whatwork
ordeferred
(where errors from the latter take precedence).Also, a new
withDockerContainer
function was added (fixes the swallowed error, which I also fixed in #58).