PyDiGraph.add_edge()
and PyGraph.add_edge
panic if an endpoint doesn't exist
#855
Labels
PyDiGraph.add_edge()
and PyGraph.add_edge
panic if an endpoint doesn't exist
#855
Information
What is the current behavior?
If you try to add an edge to a graph object with endpoints that aren't present in the graph petgraph panics and that causes an catchable exception to be raised from rustworkx without a user actionable message.
For example:
What is the expected behavior?
I think it would be better to raise an
IndexError
or a custom rustworkx exception class. The issue is aPanicException
isn't something users can catch easily (as it doesn't inherit fromException
) and is supposed to be treated as irrecoverable. Also the error message isn't something a python end user will understand. We should do checks that the indices are present in the graph before calling petgraph and return an appropriate error instead.Steps to reproduce the problem
or
The text was updated successfully, but these errors were encountered: