Check for sqlite3 constraint error

This commit is contained in:
Till Faelligen 2020-06-01 17:58:03 +02:00
parent 908edd304d
commit ab2e2ce942

View file

@ -27,8 +27,8 @@ import (
"github.com/matrix-org/gomatrixserverlib" "github.com/matrix-org/gomatrixserverlib"
"golang.org/x/crypto/bcrypt" "golang.org/x/crypto/bcrypt"
// Import the postgres database driver. // Import the sqlite3 database driver.
_ "github.com/mattn/go-sqlite3" "github.com/mattn/go-sqlite3"
) )
// Database represents an account database // Database represents an account database
@ -172,7 +172,7 @@ func (d *Database) createAccount(
} }
} }
if err := d.profiles.insertProfile(ctx, txn, localpart); err != nil { if err := d.profiles.insertProfile(ctx, txn, localpart); err != nil {
if internal.IsUniqueConstraintViolationErr(err) { if errors.Is(err, sqlite3.ErrConstraint) {
return nil, internal.ErrUserExists return nil, internal.ErrUserExists
} }
return nil, err return nil, err