fix(sqlite): we get frappe exception classes here sometimes

Signed-off-by: Akhil Narang <me@akhilnarang.dev>
This commit is contained in:
Akhil Narang 2025-03-26 18:03:29 +05:30
parent 8aed84c0d0
commit 2114a47256
No known key found for this signature in database
GPG key ID: 9DCC61E211BF645F

View file

@ -79,11 +79,15 @@ class SQLiteExceptionUtil:
@staticmethod
def is_primary_key_violation(e: sqlite3.IntegrityError) -> bool:
return e.sqlite_errorcode == 1555
if hasattr(e, "sqlite_errorcode"):
return e.sqlite_errorcode == 1555
return "UNIQUE constraint failed" in str(e)
@staticmethod
def is_unique_key_violation(e: sqlite3.IntegrityError) -> bool:
return e.sqlite_errorcode == 2067
if hasattr(e, "sqlite_errorcode"):
return e.sqlite_errorcode == 2067
return "UNIQUE constraint failed" in str(e)
@staticmethod
def is_interface_error(e: sqlite3.Error):