@@ -11,12 +11,16 @@ internal static Exception Create<T>(ExceptionProcessorInterceptor<T>.DatabaseErr
1111 {
1212 return error switch
1313 {
14- ExceptionProcessorInterceptor < T > . DatabaseError . CannotInsertNull => new CannotInsertNullException ( "Cannot insert null" , exception . InnerException , entries ) ,
15- ExceptionProcessorInterceptor < T > . DatabaseError . MaxLength => new MaxLengthExceededException ( "Maximum length exceeded" , exception . InnerException , entries ) ,
16- ExceptionProcessorInterceptor < T > . DatabaseError . NumericOverflow => new NumericOverflowException ( "Numeric overflow" , exception . InnerException , entries ) ,
17- ExceptionProcessorInterceptor < T > . DatabaseError . ReferenceConstraint => new ReferenceConstraintException ( "Reference constraint violation" , exception . InnerException , entries ) ,
18- ExceptionProcessorInterceptor < T > . DatabaseError . UniqueConstraint => new UniqueConstraintException ( "Unique constraint violation" , exception . InnerException , entries ) ,
19- ExceptionProcessorInterceptor < T > . DatabaseError . Deadlock => new DeadlockException ( "Deadlock" , exception . InnerException , entries ) ,
14+ ExceptionProcessorInterceptor < T > . DatabaseError . CannotInsertNull => new CannotInsertNullException ( "Cannot insert null" , exception , entries ) ,
15+ ExceptionProcessorInterceptor < T > . DatabaseError . MaxLength => new MaxLengthExceededException ( "Maximum length exceeded" , exception , entries ) ,
16+ ExceptionProcessorInterceptor < T > . DatabaseError . NumericOverflow => new NumericOverflowException ( "Numeric overflow" , exception , entries ) ,
17+ ExceptionProcessorInterceptor < T > . DatabaseError . ReferenceConstraint => new ReferenceConstraintException ( "Reference constraint violation" , exception , entries ) ,
18+ ExceptionProcessorInterceptor < T > . DatabaseError . UniqueConstraint => new UniqueConstraintException ( "Unique constraint violation" , exception , entries ) ,
19+ // DeadlockException intentionally has no InnerException. EF Core's ExecutionStrategy uses
20+ // CallOnWrappedException to unwrap through DbUpdateException and check InnerException for
21+ // transient errors. Setting a transient provider exception as InnerException would cause
22+ // the execution strategy to wrap DeadlockException in InvalidOperationException.
23+ ExceptionProcessorInterceptor < T > . DatabaseError . Deadlock => new DeadlockException ( "Deadlock" , null , entries ) ,
2024 _ => null ,
2125 } ;
2226 }
0 commit comments