Skip to content

Instantly share code, notes, and snippets.

@lmas
Created May 30, 2016 17:57
Show Gist options
  • Save lmas/6a96353e7bc86e0d607b650d7f36e9f2 to your computer and use it in GitHub Desktop.
Save lmas/6a96353e7bc86e0d607b650d7f36e9f2 to your computer and use it in GitHub Desktop.
// Source: https://github.com/mattn/go-sqlite3/pull/116
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?
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment