forked from Giorgi/EntityFramework.Exceptions
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPostgreSQLExceptionClassifier.cs
More file actions
15 lines (13 loc) · 1.07 KB
/
PostgreSQLExceptionClassifier.cs
File metadata and controls
15 lines (13 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
using DbExceptionClassifier.Common;
using Npgsql;
using System.Data.Common;
namespace DbExceptionClassifier.PostgreSQL;
public class PostgreSQLExceptionClassifier : IDbExceptionClassifier
{
public bool IsReferenceConstraintError(DbException exception) => exception is PostgresException { SqlState: PostgresErrorCodes.ForeignKeyViolation };
public bool IsCannotInsertNullError(DbException exception) => exception is PostgresException { SqlState: PostgresErrorCodes.NotNullViolation };
public bool IsNumericOverflowError(DbException exception) => exception is PostgresException { SqlState: PostgresErrorCodes.NumericValueOutOfRange };
public bool IsUniqueConstraintError(DbException exception) => exception is PostgresException { SqlState: PostgresErrorCodes.UniqueViolation };
public bool IsMaxLengthExceededError(DbException exception) => exception is PostgresException { SqlState: PostgresErrorCodes.StringDataRightTruncation };
public bool IsDeadlockError(DbException exception) => exception is PostgresException { SqlState: PostgresErrorCodes.DeadlockDetected };
}