0
0
Fork 1
mirror of https://mau.dev/maunium/synapse.git synced 2024-12-17 11:43:51 +01:00

Use generic db exceptions rather than sqlite3 specific ones

This commit is contained in:
Erik Johnston 2015-04-08 16:53:48 +01:00
parent a43b40449b
commit 279a547a8b
2 changed files with 2 additions and 6 deletions

View file

@ -21,8 +21,6 @@ from twisted.internet import defer
from collections import namedtuple from collections import namedtuple
import sqlite3
RoomAliasMapping = namedtuple( RoomAliasMapping = namedtuple(
"RoomAliasMapping", "RoomAliasMapping",
@ -91,7 +89,7 @@ class DirectoryStore(SQLBaseStore):
}, },
desc="create_room_alias_association", desc="create_room_alias_association",
) )
except sqlite3.IntegrityError: except self.database_engine.module.IntegrityError:
raise SynapseError( raise SynapseError(
409, "Room alias %s already exists" % room_alias.to_string() 409, "Room alias %s already exists" % room_alias.to_string()
) )

View file

@ -15,8 +15,6 @@
from twisted.internet import defer from twisted.internet import defer
from sqlite3 import IntegrityError
from synapse.api.errors import StoreError, Codes from synapse.api.errors import StoreError, Codes
from ._base import SQLBaseStore, cached from ._base import SQLBaseStore, cached
@ -76,7 +74,7 @@ class RegistrationStore(SQLBaseStore):
txn.execute("INSERT INTO users(name, password_hash, creation_ts) " txn.execute("INSERT INTO users(name, password_hash, creation_ts) "
"VALUES (?,?,?)", "VALUES (?,?,?)",
[user_id, password_hash, now]) [user_id, password_hash, now])
except IntegrityError: except self.database_engine.module.IntegrityError:
raise StoreError( raise StoreError(
400, "User ID already taken.", errcode=Codes.USER_IN_USE 400, "User ID already taken.", errcode=Codes.USER_IN_USE
) )