-
Notifications
You must be signed in to change notification settings - Fork 82
Open
Description
cc @adrianna-chang-shopify @casperisfine @composerinteralia @dhruvCW @matthewd
We made some improvements to the Ruby extension's error classes recently but based on recent discussions I think still have a way to go. I wanted to gather opinions in this issue and am happy to implement what we can come to a consensus on.
Problems I see:
- QueryError is our default fallback error class. I don't think this makes any sense, as this is a ProtocolError subclass but all errors other than TRILOGY_ERR are IMO connection-level errors. I think we should make
BaseConnectionErrorthe default error class for things which haven't been given a specific meaning (alternatively we could exhaustively define error classes for all trilogy status codes). - "TRILOGY_CLOSED_CONNECTION". This error represents essentially an EOF over our socket, and it's one of the more common errors we come across. It's also the error we'll see if we attempt communication after a
trilogy_sock_shutdown. Currently this appears asQueryError: TRILOGY_CLOSED_CONNECTIONand we're forced to do string matching to detect it. I think this deserves its own error class, but also it should probably be distinct fromConnectionClosed, which is only raised from an explicitly closed connection. How aboutTrilogy::EOFError? For backwards compatibility I'd probably include "TRILOGY_CLOSED_CONNECTION" in the string.- Another possibility I'd like to entertain is deleting the translation of EPIPE errors to
TRILOGY_CLOSED_CONNECTION, which would break compatibility with those doing string matching but I think otherwise is just better and more accurate information.
- Another possibility I'd like to entertain is deleting the translation of EPIPE errors to
- SyscallError vs ConnectionError. As raised in Handle EADDRNOTAVAIL as a BaseConnectionError instead of SyscallError #98, there's some confusion between SyscallError and BaseConnectionError. One option is that we can make
Trilogy::SyscallErrorinherit fromConnectionErrorand then have only one thing to rescue, or we could better document that users should rescue both classes (I don't feel very strongly either way). - I think
ProtocolError's name is confusing. I read this as "protocol violation" rather than "we were told over the protocol that an error occurred", and I've seen confusion from others about the same. I preferred the previousDatabaseErrornaming but am open to other options. How aboutServerError"an error reported by the server"? Whatever we choose we can make the classes aliases of each other, so there should be minimal compatibility problems.
dhruvCWdhruvCWdhruvCW
Metadata
Metadata
Assignees
Labels
No labels