• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Giorgi / EntityFramework.Exceptions / 23549203342

25 Mar 2026 03:28PM UTC coverage: 91.209% (-0.2%) from 91.429%
23549203342

push

github

Giorgi
Do not process low-level command failed when the operation is SaveChanges. Fixes #96

128 of 151 branches covered (84.77%)

Branch coverage included in aggregate %.

17 of 19 new or added lines in 2 files covered. (89.47%)

1 existing line in 1 file now uncovered.

204 of 213 relevant lines covered (95.77%)

36.45 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

91.3
/EntityFramework.Exceptions/Common/ExceptionFactory.cs
1
using System;
2
using System.Collections.Generic;
3
using System.Data.Common;
4
using Microsoft.EntityFrameworkCore.ChangeTracking;
5

6
namespace EntityFramework.Exceptions.Common;
7

8
static class ExceptionFactory
9
{
10
    internal static Exception Create<T>(ExceptionProcessorInterceptor<T>.DatabaseError error, Exception exception, IReadOnlyList<EntityEntry> entries) where T : DbException
11
    {
127✔
12
        return error switch
127!
13
        {
127✔
14
            ExceptionProcessorInterceptor<T>.DatabaseError.CannotInsertNull => new CannotInsertNullException("Cannot insert null", exception, entries),
20✔
15
            ExceptionProcessorInterceptor<T>.DatabaseError.MaxLength => new MaxLengthExceededException("Maximum length exceeded", exception, entries),
16✔
16
            ExceptionProcessorInterceptor<T>.DatabaseError.NumericOverflow => new NumericOverflowException("Numeric overflow", exception, entries),
12✔
17
            ExceptionProcessorInterceptor<T>.DatabaseError.ReferenceConstraint => new ReferenceConstraintException("Reference constraint violation", exception, entries),
40✔
18
            ExceptionProcessorInterceptor<T>.DatabaseError.UniqueConstraint => new UniqueConstraintException("Unique constraint violation", exception, entries),
34✔
19
            // DeadlockException intentionally has no InnerException. EF Core's ExecutionStrategy uses
127✔
20
            // CallOnWrappedException to unwrap through DbUpdateException and check InnerException for
127✔
21
            // transient errors. Setting a transient provider exception as InnerException would cause
127✔
22
            // the execution strategy to wrap DeadlockException in InvalidOperationException.
127✔
23
            ExceptionProcessorInterceptor<T>.DatabaseError.Deadlock => new DeadlockException("Deadlock", null, entries),
5✔
UNCOV
24
            _ => null,
×
25
        };
127✔
26
    }
127✔
27
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc