This repository was archived by the owner on Nov 2, 2022. It is now read-only.
very-very first version decorator-based exception catch API (Introduce HandlerChain) #18
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.
I have tried to implement with the way using
HandlerChain
(which is close to the last proposol inside #5 I think.)But for now it's just handle for the simlest case: the handled exc is not an instance of ExceptionGroup. (the
exc
can be an instance ofExceptionGroup
, but the output traceback information is not so clearly.)Sorry for the disturb......I'm afraid my solution is too bad to go on :(
So I submit this PR, hope it can help us to see the new picture.
=======================================
For the actual changes:
It's a little different to the last proposol, which is:
In the PR here, the usage is:
After a little thought about it, I think if we use HandlerChain, we can re-use the chain when we need it, so we don't need to re-define function inside every
with
block. And we can write code like this:Note that there are decisions make by the handler:
with handler
raise Exception, the handler will always raise an instance ofExceptionGroup
.I have add the test_script named
handler.py
, we can run the script to see what's going on there :)