forked from Giorgi/EntityFramework.Exceptions
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOracleExceptionClassifier.cs
More file actions
29 lines (21 loc) · 1.38 KB
/
OracleExceptionClassifier.cs
File metadata and controls
29 lines (21 loc) · 1.38 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
25
26
27
28
29
using System.Data.Common;
using DbExceptionClassifier.Common;
using Oracle.ManagedDataAccess.Client;
namespace DbExceptionClassifier.Oracle;
public class OracleExceptionClassifier : IDbExceptionClassifier
{
private const int CannotInsertNull = 1400;
private const int CannotUpdateToNull = 1407;
private const int UniqueConstraintViolation = 1;
private const int DeadLock = 60;
private const int IntegrityConstraintViolation = 2291;
private const int ChildRecordFound = 2292;
private const int NumericOverflow = 1438;
private const int NumericOrValueError = 12899;
public bool IsReferenceConstraintError(DbException exception) => exception is OracleException { Number: IntegrityConstraintViolation or ChildRecordFound };
public bool IsCannotInsertNullError(DbException exception) => exception is OracleException { Number: CannotInsertNull or CannotUpdateToNull };
public bool IsNumericOverflowError(DbException exception) => exception is OracleException { Number: NumericOverflow };
public bool IsUniqueConstraintError(DbException exception) => exception is OracleException { Number: UniqueConstraintViolation };
public bool IsMaxLengthExceededError(DbException exception) => exception is OracleException { Number: NumericOrValueError };
public bool IsDeadlockError(DbException exception) => exception is OracleException { Number: DeadLock };
}