3

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?

Tony Ennis
  • 12,000
  • 7
  • 52
  • 73
  • Can't you just write `except CypherExecutionException:`? If you can't, you can catch any exception with `except:`, though if there can be other exceptions there, it's not a good option. – Ilya Peterov Sep 24 '15 at 14:56
  • I can but it is flagged as an unresolved reference in my IDE. This is not acceptable. I caught it with except Exception for now so I can get on with it. But I clearly lack a skill. – Tony Ennis Sep 24 '15 at 15:02

1 Answers1

1

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.

Nigel Small
  • 4,475
  • 1
  • 17
  • 15