Handle PG::ConnectionBad from PG#server_version similarly to version 0#54731
Conversation
|
Isn't it already handled by |
Ah yes, however that raises If that's fine, should we update the explicit version 0 raise to match? |
|
If the error message isn't good, we can handle that centrally in |
aba78e4 to
65d7ba8
Compare
I've actioned this and made the version 0 logic raise a Alternatively we just keep the duplication. |
| ConnectionFailed.new(exception, connection_pool: @pool) | ||
| else | ||
| ConnectionNotEstablished.new(exception, connection_pool: @pool) | ||
| message = if exception.message.match?(/can't get server version/i) |
There was a problem hiding this comment.
I really don't think we should be rewriting error messages here, the original message is fine
There was a problem hiding this comment.
Okay I've updated, all this does now is ensure the error classes are consistent.
65d7ba8 to
407f3dc
Compare
407f3dc to
2aba1f5
Compare
PG::ConnectionBad from PG#server_version similar to version 0PG::ConnectionBad from PG#server_version similarly to version 0
Motivation / Background
Follow-up to #54713 and ged/ruby-pg#632.
Detail
Now that in future versions pg will raise
PG::ConnectionBadwhen attempting to get the database version with a bad connection, we should handle it the same as when a version of 0 returned.I opted to not preserve the error message from pg cause it's a bit too specific to the native implementation. Getting the message across to the user that the root of the failure is a bad connection should suffice imo.
cc @byroot
Additional information
N/A
Checklist
Before submitting the PR make sure the following are checked:
[Fix #issue-number]