Skip to content

Conversation

c14n
Copy link
Contributor

@c14n c14n commented Apr 1, 2014

This pull request adds an additional field ExtendedCode for extended SQLite3 error codes as defined in https://www.sqlite.org/c3ref/c_abort_rollback.html to the Error type, and defines constants for those error types.

This pull request is fully backwards compatible with code like:

if err.(sqlite3.Error).Code == sqlite3.ErrConstraint {
    // clumsily compare err.Error() against strings to figure out what the heck happened...
}

Additionally, the following is now possible:

if err.(sqlite3.Error).ExtendedCode == sqlite3.ErrConstraintUnique {
    // oh! my unique constraint failed?
}

Cheers!

mattn added a commit that referenced this pull request Jun 25, 2014
Enable extended error codes.
@mattn mattn merged commit a59fbb4 into mattn:master Jun 25, 2014
@mattn
Copy link
Owner

mattn commented Jun 25, 2014

Thank you

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.

2 participants