Skip to content

Wrap drivers.ErrBadConn - #1457

Open
arp242 wants to merge 2 commits into
mainfrom
badconn
Open

arp242 wants to merge 2 commits into
mainfrom
badconn

Conversation

@arp242

@arp242 arp242 commented Nov 16, 2026

Copy link
Copy Markdown
Collaborator

I have an application that keeps failing with "driver: bad connection" and no other error or details. I'm not sure if this is wrong usage on my part, a server problem or a pq problem, but just returning driver.ErrBadConn is not exactly easy to debug.

So wrap the error in cases where driver.ErrBadConn is used without returning an error. When this code was written %w didn't exist yet, but now it does and I verified that database/sql uses errors.Is().

Hopefully I have all instances of those(?) I'll run this PR and see what happens.

I have an application that keeps failing with "driver: bad connection"
and no other error or details. I'm not sure if this is wrong usage on my
part, a server problem or a pq problem, but just returning
driver.ErrBadConn is not exactly easy to debug.

So wrap the error in cases where driver.ErrBadConn is used without
returning an error. When this code was written %w didn't exist yet, but
now it does and I verified that database/sql uses errors.Is().

Hopefully I have all instances of those(?) I'll run this PR and see what
happens.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant