Skip to content

Commit

Permalink
feat(sqlcon): catch sqlite primary key violations (#417)
Browse files Browse the repository at this point in the history
  • Loading branch information
aeneasr authored Oct 23, 2021
1 parent 7300ebd commit ceab011
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions sqlcon/error_sqlite.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,11 @@ func handleSqlite(err error) error {
if e := new(sqlite3.Error); errors.As(err, e) {
switch e.ExtendedCode {
case sqlite3.ErrConstraintUnique:
fallthrough
case sqlite3.ErrConstraintPrimaryKey:
return errors.Wrap(ErrUniqueViolation, err.Error())
}

switch e.Code {
case sqlite3.ErrError:
if strings.Contains(err.Error(), "no such table") {
Expand Down

0 comments on commit ceab011

Please sign in to comment.