neo4j-labs / neo4rs

Rust driver for Neo4j
https://docs.rs/neo4rs
202 stars 59 forks source link

Unexpected response returned for syntax errors #169

Closed madchicken closed 2 months ago

madchicken commented 5 months ago

When executing a Cypher query that contains a syntax error, execute returns an UnuexpectedError that contains a string that is a debug representation of Failure, like:

"unexpected response for RUN: Ok(Failure(Failure { metadata: BoltMap { value: {BoltString { value: "message" }: String(BoltString { value: "Variable `Baz` not defined (line 1, column 49 (offset: 48))\n\"MATCH (Foo: Foo)-[:HAS]->(Bar: Bar) RETURN Foo, Baz\"\n                                                                                                                                                                                                                                                                                                                                                                                                                                                           ^" }), BoltString { value: "code" }: String(BoltString { value: "Neo.ClientError.Statement.SyntaxError" })} } }))"

It would be great to have a dedicated Error for Neo.ClientError.Statement.SyntaxError or get back the BoltMap containing the message key.

knutwalker commented 2 months ago

I added an dedicated enum case to handle this in 0.8.0. You can get the code and the message as &strs

I am probably not adding typed versions for the different error codes, as those code are not guaranteed to be stable from the server and might change at some point.