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

Question: Why do PluginError have a cause argument to the constructor ? #47

Open
Carreau opened this issue Dec 23, 2021 · 3 comments
Open

Comments

@Carreau
Copy link
Contributor

Carreau commented Dec 23, 2021

It seem to like this is trying to do the same as

except ... as e:
     raise PluginError(...) from e

The "from" seem to set the __cause__ the same way the argument does.

It looks like @tlambert03 wrote the code, maybe he knows ?

@tlambert03
Copy link
Contributor

tlambert03 commented Dec 23, 2021

yes, it's doing the same thing. Recall though that one of the main designs of plugin errors was to not raise them, so adding __cause__ is the same as raising from, but without raising. If you'd prefer to raise/catch rather than do it like this, as you did over in the napari PRs, that's fine... same ultimate goal.

(you could do the same thing with tracebacks over there too... but it doesn't matter too much to me. whatever gets the job done)

@Carreau
Copy link
Contributor Author

Carreau commented Dec 23, 2021

Main problem is that if not raising PluginErrors, then the ExecInfo will not have a __traceback__ which will crash the IPython traceback formatter in IPython 8.0+. So I'm fine with the PluginError(cause=e), but I'm a bit worried about the pattern of creating plugin errors that are exception w/o raising them

@tlambert03
Copy link
Contributor

Yeah, I saw that. Like I said, I suspect you could also add a __traceback__ just as I added __cause__ ... but it really doesn't matter to me. whatever you want to do works for me.

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