Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How could it raise error rather than catch? #24

Closed
ZhangSanMo opened this issue Dec 7, 2022 · 5 comments
Closed

How could it raise error rather than catch? #24

ZhangSanMo opened this issue Dec 7, 2022 · 5 comments

Comments

@ZhangSanMo
Copy link

code

import curio
import async_btree as bt
def div_zero():
    1/0

result = curio.run(bt.action(div_zero))
assert result is not None

question

curio run normaly and return None, but I except it panic !

expect

The code panic and report trackstack rather than normal running.

@geronimo-iia
Copy link
Owner

Hello, it should raise a ControlFlowException,
I just check quickly with a test unit, and something is wrong as you noticed.
I dont known yet where this behaviour came from, we stay in touch

@geronimo-iia
Copy link
Owner

I found where came from the mistake.

ControlFlowException was made with a falsy meaning value in order to manage this one like a False result in other operator. But, with a False meaning, it seems that it didnt raise normaly. I had to confim that and find a way to do all that stuff better.

@geronimo-iia
Copy link
Owner

I think that :

  • removing all try/catch and ControlFlowException usage
  • add few function like failure_on_exception / success_on_exception (func, exception name)

could offer a better way to deal with exception like a normal usage of python syntax do.

@ZhangSanMo
Copy link
Author

Thank you for your efforts.

@geronimo-iia
Copy link
Owner

In the last release (1.2.0), i made "few" changes about exception handling.
By default, exception are not catch.
We can ignore (with a falsy meaning) them with ignore_exception.
For always_success/always_failure, exception are encaspulated with ControlFlowException and raised.
This permit us to keep exception flow as usual or catch them and manipulate them with another btree branch.
I'm not sure if it's a good idea or not, so don't hesite to share your advice :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants