Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
02-17-2022 11:55 AM
My understanding of Python is that user-defined exceptions are supposed to extend the built-in RuntimeError class.
Here's some code that I expect to work:
def isAvailableDatabase_(self, aDatabaseName):
cypherQuery = f"""SHOW DATABASE `{aDatabaseName}` YIELD currentStatus"""
with self.neo4JAdapterPreset() as adapter:
with adapter.sessionWithParameters_(database='system') as session:
try:
result = session.run(cypherQuery)
record= result.single()
isAvailable = (record is not None) and ('online' == record['currentStatus'])
except RuntimeError as runtimeError:
exceptionStr = str(runtimeError)
complaint = f"""Raised {exceptionStr}"""
print(complaint)
return False
I want this method to simply return False
when the database isn't available, such as while Neo4J is not running. The stuff inside the exception handler is just so that I can see what's happening.
I want truly awful and unexpected exceptions to NOT be caught. I don't want to "leak" the Neo4J-specific exceptions from the official Python driver into this code.
Is there a straightforward way to catch an ancestor of the several exceptions defined in the official Python driver for Neo4J?
All the sessions of the conference are now available online