bchavez / RethinkDb.Driver

:headphones: A NoSQL C#/.NET RethinkDB database driver with 100% ReQL API coverage.
http://rethinkdb.com/api/java
Other
383 stars 134 forks source link

Add Error codes to Exceptions #145

Closed oliverjanik closed 4 years ago

oliverjanik commented 4 years ago

If I'm not mistaken I can't tell the difference between

RethinkDb.Driver.ReqlOpFailedError
Cannot perform read: primary replica for shard ["", +inf) not available

and

RethinkDb.Driver.ReqlOpFailedError
Table `example.order_form_data` does not exist.

correct?

I'm looking into availability and it's worth retrying on the first error but not on the second one.

If exceptions had error codes or some other way of telling them apart (message text notwithstanding) that would enable me to write more granular retry policies.

bchavez commented 4 years ago

Exceptions like ReqlOpFailedError are built into the protocol. If the protocol doesn't provide an error code, the driver can't provide one either.

https://github.com/bchavez/RethinkDb.Driver/blob/044749812e51b918c09724cbe54a7d99e281cfc1/Source/RethinkDb.Driver/ErrorBuilder.cs#L39-L87

https://github.com/bchavez/RethinkDb.Driver/blob/044749812e51b918c09724cbe54a7d99e281cfc1/Source/RethinkDb.Driver/Generated/Proto/ResponseType.cs#L11-L20

https://github.com/bchavez/RethinkDb.Driver/blob/044749812e51b918c09724cbe54a7d99e281cfc1/Source/RethinkDb.Driver/Generated/Proto/ErrorType.cs#L11-L20

Try turning on protocol debugging, trace both exceptions over the wire, and see if you can detect anything different besides the error msg string in both JSON responses.

If you can detect some other discriminator value (like an error code), re-open the issue and let me know and I'll take a look at adding it. IIRC, it is not possible with the current server protocol implementation.

Hope that helps, Brian

oliverjanik commented 4 years ago

Too bad, I thought that might be the case. Thanks for detailed response.