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

Giorgi / EntityFramework.Exceptions / 12006111989

25 Nov 2024 08:31AM UTC coverage: 87.949% (+5.1%) from 82.857%
12006111989

push

github

web-flow
Merge pull request #82 from MarkusG/use-dbcommand-interceptor

137 of 172 branches covered (79.65%)

Branch coverage included in aggregate %.

31 of 33 new or added lines in 2 files covered. (93.94%)

1 existing line in 1 file now uncovered.

206 of 218 relevant lines covered (94.5%)

28.01 hits per line

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

84.21
/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
    {
122✔
12
        if (entries?.Count > 0)
122✔
13
        {
16✔
14
            return error switch
16!
15
            {
16✔
16
                ExceptionProcessorInterceptor<T>.DatabaseError.CannotInsertNull => new CannotInsertNullException( "Cannot insert null", exception.InnerException, entries),
2✔
17
                ExceptionProcessorInterceptor<T>.DatabaseError.MaxLength => new MaxLengthExceededException( "Maximum length exceeded", exception.InnerException, entries),
2✔
NEW
18
                ExceptionProcessorInterceptor<T>.DatabaseError.NumericOverflow => new NumericOverflowException( "Numeric overflow", exception.InnerException, entries),
×
19
                ExceptionProcessorInterceptor<T>.DatabaseError.ReferenceConstraint => new ReferenceConstraintException( "Reference constraint violation", exception.InnerException, entries),
4✔
20
                ExceptionProcessorInterceptor<T>.DatabaseError.UniqueConstraint => new UniqueConstraintException( "Unique constraint violation", exception.InnerException, entries),
8✔
NEW
21
                _ => null,
×
22
            };
16✔
23
        }
24

25
        return error switch
106!
26
        {
106✔
27
            ExceptionProcessorInterceptor<T>.DatabaseError.CannotInsertNull => new CannotInsertNullException("Cannot insert null", exception.InnerException),
16✔
28
            ExceptionProcessorInterceptor<T>.DatabaseError.MaxLength => new MaxLengthExceededException("Maximum length exceeded", exception.InnerException),
14✔
29
            ExceptionProcessorInterceptor<T>.DatabaseError.NumericOverflow => new NumericOverflowException("Numeric overflow", exception.InnerException),
14✔
30
            ExceptionProcessorInterceptor<T>.DatabaseError.ReferenceConstraint => new ReferenceConstraintException("Reference constraint violation", exception.InnerException),
36✔
31
            ExceptionProcessorInterceptor<T>.DatabaseError.UniqueConstraint => new UniqueConstraintException("Unique constraint violation", exception.InnerException),
26✔
UNCOV
32
            _ => null,
×
33
        };
106✔
34
    }
122✔
35
}
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

© 2025 Coveralls, Inc