Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
While working on BitTorrent stuff and trying to keep exceptions checked, I continuously hit the wall of set of "stores" which mostly do not use anything but
.async.
.This PR adds checked exceptions to all stores and dependent abstractions.
To keep the PR still maintainable it focuses on the "stores", thus it has pretty much a minimal set of changes to get them compile.
Most of the changes are easy and syntactical, but there were a few exceptions where it was a big pain to move forward.
It all boils down to
AsynIter
, most probably created beforeasync: (raises: [CancelledError])
era, that makes checking exceptions much harder where it is used.The only way to get it clean was for me to create a version of AsyncIter (called
SafeAsyncIter
) that usesResults
and only ever allows forasync: (raises: [CancelledError])
. I applied it tolistBlocks
andgetBlockExpirations
and doing this I could remove problematic situations (especially in block maintenance).SafeAsynIter
has the same API asAsynIter
and requires very little work (pretty much syntactical) to use it in place ofAsyncIter
, which is still used in some other places, which can be dealt with in a separate PR to keep this one small.To get some insights about challenges that you may encounter when working with checked (raising) exception, you may like to check the following note: https://publish.obsidian.md/bittorrent/10+Notes/Async+checked+(raising)+exceptions.