Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
10-22-2022 05:53 AM - edited 10-22-2022 05:58 AM
Sometimes we need to utilise triggers (apoc.trigger.add) to implement a functional constraint in database operation.
The usual way of having this work is to make use of apoc.util.validate, and this raises an exception in Neo4j.
Apart from parsing every single error message from the driver for the exact string matching the exepected error message, is there any way of catching those errors raised by apoc.util.validate, or, as I suspect, is it impossible due to the way it seems the drivers are implemented? I'm using the Go driver.
Edit: I see that in Python and Java driver implementations it is possible to catch specific exception types.
01-26-2023 01:18 AM
Hello, sorry for the late reply, this fell off my radar.
You can run something like this:
if neo4jErr, ok := err.(*neo4j.Neo4jError); ok {
// example raw error is: Neo.ClientError.General.ForbiddenReadOnlyDatabase
classification := neo4jErr.Classification() // ClientError
category := neo4jErr.Category() // General
title := neo4jErr.Title() // ForbiddenReadOnlyDatabase
// do something with these
}
All the sessions of the conference are now available online