You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This causes some friction, as I need conditional logic based on this error. The only way now is with string matching, which is not guaranteed to be stable across releases.
Can this instead be a public error const, like ErrTLSNotSupported?
Similarly, I need conditional logic for connection errors, but that error is private now. See
I think it is reasonable to make it easier to programmatically handle specific errors.
But error constants and error types become part of the public interface and a tricky part at that. It's much less obvious that there has been a breaking change when a function signature changes than when a returned error changes. This is why I default to untyped / unexported errors.
That said, I think the two changes you suggest are reasonable and may even be optimal, but I'd like you to also consider whether an error interface (like net.Error) or type testing functions (like pgconn.SafeToRetry) would be a better interface. Your original suggestion is probably best but please consider alternatives as well.
I am working on a CLI tool that uses this library.
Currently, pgconn returns an untyped error for "server refused TLS." See
pgconn/pgconn.go
Line 379 in 7ddbd74
This causes some friction, as I need conditional logic based on this error. The only way now is with string matching, which is not guaranteed to be stable across releases.
Can this instead be a public error const, like
ErrTLSNotSupported
?Similarly, I need conditional logic for connection errors, but that error is private now. See
pgconn/errors.go
Line 60 in 7ddbd74
Can that struct be made publicly visible, similar to
PgError
?If you agree, I don't mind working on the PR.
The text was updated successfully, but these errors were encountered: