Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Associate PostgresConnectionClosedException with error code 08006 #538

Closed
rgmz opened this issue Aug 4, 2022 · 3 comments
Closed

Associate PostgresConnectionClosedException with error code 08006 #538

rgmz opened this issue Aug 4, 2022 · 3 comments
Labels
type: enhancement A general enhancement
Milestone

Comments

@rgmz
Copy link

rgmz commented Aug 4, 2022

Feature Request

Is your feature request related to a problem? Please describe

When the connection is closed unexpectedly it throws a PostgresConnectionClosedException. I would like to handle this scenario programmatically, however, it currently isn't possible to catch PostgresConnectionClosedException because it's package-private.

static class PostgresConnectionClosedException extends R2dbcNonTransientResourceException {
public PostgresConnectionClosedException(String reason) {
super(reason);
}
public PostgresConnectionClosedException(String reason, @Nullable Throwable cause) {
super(reason, cause);
}
}

For example, if I'm listening to notifications and want to restart the connection or channel.

Describe the solution you'd like

I would like for PostgresConnectionClosedException to be public so it can be explicitly caught.

Describe alternatives you've considered

Presently the only alternative I'm aware of is catching R2dbcNonTransientResourceException and checking for the "UNEXPECTED" error message. This isn't ideal because it's not as clear as catching the specific exception, and the message could change in the future.

@rgmz rgmz added the type: enhancement A general enhancement label Aug 4, 2022
@mp911de
Copy link
Collaborator

mp911de commented Aug 5, 2022

Any R2dbcNonTransientResourceException that does not implement the PostgresqlException is an exceptional state that requires recovery. Driver exceptions that implement PostgresqlException are error notifications sent by the database. PostgresConnectionClosedException is a client-side exception and therefore it does not implement PostgresqlException.

We do not want to expose internal exception types as the specification already defines a public API for exception signals.

@mp911de mp911de closed this as not planned Won't fix, can't repro, duplicate, stale Aug 5, 2022
@mp911de mp911de added status: declined A suggestion or change that we don't feel we should currently apply and removed type: enhancement A general enhancement labels Aug 5, 2022
@rgmz
Copy link
Author

rgmz commented Aug 5, 2022

We do not want to expose internal exception types as the specification already defines a public API for exception signals.

Would including specific error codes in R2dbcNonTransientResourceException be a viable alternative? The MariaDB implementation includes relevant error codes (e.g. 0800), and including Postgres error codes would be more meaningful than matching the exception reason.

@mp911de mp911de reopened this Aug 8, 2022
@mp911de
Copy link
Collaborator

mp911de commented Aug 8, 2022

Thanks for the suggestion. Reporting connection failure with the error code 08006 makes sense.

@mp911de mp911de changed the title Make PostgresConnectionClosedException public Associate PostgresConnectionClosedException with error code 08006 Aug 8, 2022
@mp911de mp911de added type: enhancement A general enhancement and removed status: declined A suggestion or change that we don't feel we should currently apply labels Aug 8, 2022
@mp911de mp911de added this to the 1.0.0.RC2 milestone Aug 8, 2022
mp911de added a commit that referenced this issue Aug 8, 2022
We now provide error details for client-side exceptions for easier handling of failures.

[resolves #538]

Signed-off-by: Mark Paluch <mpaluch@vmware.com>
@mp911de mp911de closed this as completed in 49825d8 Aug 8, 2022
@mp911de mp911de modified the milestones: 1.0.0.RC2, 0.9.2.RELEASE Aug 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

2 participants