Search code examples
pythonneo4jpy2neo

import for py2neo.error.CypherExecutionException


I'm expectedly getting a CypherExecutionException. I would like to catch it but I can't seem to find the import for it.

Where is it? How do I find it myself next time?


Solution

  • Depending on which version of py2neo you're using, and which Cypher endpoint - legacy or transactional - this may be one of the auto-generated errors built dynamically from the server response. Newer functionality (i.e. the transaction endpoint) no longer does this and instead holds hard-coded definitions for all exceptions for just this reason. This wasn't possible for the legacy endpoint when the full list of possible exceptions was undocumented.

    You should however be able to catch py2neo.error.GraphError instead which is the base class from which these dynamic errors inherit. You can then study the attributes of that error for more specific checking.