-
-
Notifications
You must be signed in to change notification settings - Fork 82
Expand file tree
/
Copy pathSqliteExceptionClassifier.cs
More file actions
24 lines (17 loc) · 1.07 KB
/
SqliteExceptionClassifier.cs
File metadata and controls
24 lines (17 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
using DbExceptionClassifier.Common;
using Microsoft.Data.Sqlite;
using System.Data.Common;
using static SQLitePCL.raw;
namespace DbExceptionClassifier.Sqlite;
public class SqliteExceptionClassifier : IDbExceptionClassifier
{
public bool IsReferenceConstraintError(DbException exception) => exception is SqliteException { SqliteExtendedErrorCode: SQLITE_CONSTRAINT_FOREIGNKEY };
public bool IsCannotInsertNullError(DbException exception) => exception is SqliteException { SqliteExtendedErrorCode: SQLITE_CONSTRAINT_NOTNULL };
public bool IsNumericOverflowError(DbException exception) => false;
public bool IsUniqueConstraintError(DbException exception) => exception is SqliteException
{
SqliteExtendedErrorCode: SQLITE_CONSTRAINT_UNIQUE or SQLITE_CONSTRAINT_PRIMARYKEY
};
public bool IsMaxLengthExceededError(DbException exception) => exception is SqliteException { SqliteExtendedErrorCode: SQLITE_TOOBIG };
public bool IsDeadlockError(DbException exception) => exception is SqliteException { SqliteExtendedErrorCode: SQLITE_LOCKED_SHAREDCACHE};
}