rustworkx icon indicating copy to clipboard operation
rustworkx copied to clipboard

Panic on PruneSearch

Open barakatzir opened this issue 10 months ago • 1 comments

When raising PruneSearch in the finish_vertex traversal event, the traversal methods raise PanicError.

I suggest raising RuntimeError instead. This properly inherits from Exception (and not only from BaseException) and has a specific type a user can try: ...; except RunimeError: ....

Panic also has a side effect of printing to stderr a panic message (other than the python-raised exception traceback). I think this stderr message should be avoided if possible, but I'm not sure there is an easy solution for this (other than the breaking change of rustworkx-core not panicking).

This was raised in issue https://github.com/Qiskit/rustworkx/issues/1361, which was closed in PR https://github.com/Qiskit/rustworkx/pull/1375. I guess this point got drowned in the documentation change discussions, so I'm opening a new issue for it here. (The raised exception in the finish event was added to the rustworkx docs in that PR with the exception type unmentioned).

If there is already a PR for this, or this enhancement is unwanted feel free to close this issue.

barakatzir avatar Feb 10 '25 07:02 barakatzir

Yes, we marked the PR as closing the issue. Reopening is fine, we should track the unwanted panics.

IvanIsCoding avatar Feb 10 '25 14:02 IvanIsCoding