Closed flip111 closed 8 years ago
Alternatively an easy improvement without have to create tons of exception classes would be to make the code available on the exception as property. Right now this information is pushed inside a string and not accesible anymore
This is how the code would look like in that case:
function createUser() {
try {
$client->sendCypherQuery('CREATE (n:user {username:"flip111"})');
} catch (\Neo4jException $e) {
if ($e->getCode() === 'Neo.ClientError.Schema.ConstraintViolation') {
// notify the user somehow the user already exist
} else {
throw $e;
}
}
// Other exceptions are not caught and can display a 500 Internal Server error page
}
(not really sure if that getter is really needed, perhaps a simple property will do)
This is a planned stuff.
:+1:
This is an example of an exception i get
It would be nice to have a specific exception for this. Maybe the class can be called
ConstraintViolationException
. Then what i can do in the code is:It would require creating exception based on the exception code. (That would also require knowing all the possible exception codes, which i don't know where to find a list for)