Diesel: Add `DatabaseErrorKind` variants for connection errors

Created on 8 Mar 2020  路  4Comments  路  Source: diesel-rs/diesel

On 1.4.3, if you lose your connection to a postgres database and try to make a query you will get:

Err(
    DatabaseError(
        __Unknown,
        "server closed the connection unexpectedly\n\tThis probably means the server terminated abnormally\n\tbefore or while processing the request.\n",
    ),
)

or

Err(
    DatabaseError(
        UnableToSendCommand,
        "no connection to the server\n",
    ),
)

For obvious reasons, It would be useful to be able to identify a bad connection.

assigned enhancement help wanted

All 4 comments

We are happy to accept a PR adding this error variant

I would like to work on this issue.

@henryboisdequin Feel free to go for it :+1:

@henryboisdequin Feel free to go for it :+1:

Was this page helpful?
0 / 5 - 0 ratings