Skip to content

Figure out error handling #2

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

Closed
sfackler opened this issue Aug 26, 2013 · 0 comments
Closed

Figure out error handling #2

sfackler opened this issue Aug 26, 2013 · 0 comments
Assignees

Comments

@sfackler
Copy link
Owner

On master, everything returns a Result<T, ~str>. On native, error "handling" is task failure. Neither of these options are particularly great.

The Result strategy imposes an annoying burden on users who don't care about handling SQL syntax errors in the common case. ~str is also not the appropriate type for errors, but that's more easily fixable.

On the other hand, users do sometimes want to do reasonable things with failure, especially when connecting and potentially when querying (e.g. if you wanted to rewrite psql).

One option is to have something like

impl PostgresConnection {
    pub fn connect(url: &Url) -> PostgresConnection {
        match PostgresConnection::try_connect(url) {
            Ok(conn) => conn,
            Err(err) => fail!(err)
        }
    }

    pub fn try_connect(url: &Url) -> Result<PostgresConnection, PostgresConnectionError> {
        ....
    }
}

and so on for all of the relevant methods. I think this is probably the most workable solution.

Whatever the solution is, the error object type should be robust. We should be able to parse the SQLSTATE value of the ErrorResult to get things like NotNullViolation vs ForeignKeyViolation.

@ghost ghost assigned sfackler Aug 26, 2013
@Ryman Ryman mentioned this issue Nov 19, 2014
karolisg pushed a commit to getdozer/rust-postgres that referenced this issue Nov 2, 2022
config: add sslmode `verify-ca` and `verify-full`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant