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

Giorgi / EntityFramework.Exceptions / 293

16 Mar 2024 12:43PM CUT coverage: 81.25% (+1.0%) from 80.292%
293

push

appveyor

Giorgi
Add ConstraintName to UniqueConstraintException

117 of 144 relevant lines covered (81.25%)

12.7 hits per line

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

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

7
namespace EntityFramework.Exceptions.Common;
8

9
static class ExceptionFactory
10
{
11
    internal static Exception Create<T>(ExceptionProcessorInterceptor<T>.DatabaseError error, DbUpdateException exception, IReadOnlyList<EntityEntry> entries) where T : DbException
12
    {
64✔
13
        return error switch
64✔
14
        {
64✔
15
            ExceptionProcessorInterceptor<T>.DatabaseError.CannotInsertNull when entries.Count > 0 => new CannotInsertNullException("Cannot insert null", exception.InnerException, entries),
20✔
16
            ExceptionProcessorInterceptor<T>.DatabaseError.CannotInsertNull when entries.Count == 0 => new CannotInsertNullException("Cannot insert null", exception.InnerException),
×
17
            ExceptionProcessorInterceptor<T>.DatabaseError.MaxLength when entries.Count > 0 => new MaxLengthExceededException("Maximum length exceeded", exception.InnerException, entries),
16✔
18
            ExceptionProcessorInterceptor<T>.DatabaseError.MaxLength when entries.Count == 0 => new MaxLengthExceededException("Maximum length exceeded", exception.InnerException),
×
19
            ExceptionProcessorInterceptor<T>.DatabaseError.NumericOverflow when entries.Count > 0 => new NumericOverflowException("Numeric overflow", exception.InnerException, entries),
12✔
20
            ExceptionProcessorInterceptor<T>.DatabaseError.NumericOverflow when entries.Count == 0 => new NumericOverflowException("Numeric overflow", exception.InnerException),
×
21
            ExceptionProcessorInterceptor<T>.DatabaseError.ReferenceConstraint when entries.Count > 0 => new ReferenceConstraintException("Reference constraint violation", exception.InnerException, entries),
40✔
22
            ExceptionProcessorInterceptor<T>.DatabaseError.ReferenceConstraint when entries.Count == 0 => new ReferenceConstraintException("Reference constraint violation", exception.InnerException),
×
23
            ExceptionProcessorInterceptor<T>.DatabaseError.UniqueConstraint when entries.Count > 0 => new UniqueConstraintException("Unique constraint violation", exception.InnerException, entries),
40✔
24
            ExceptionProcessorInterceptor<T>.DatabaseError.UniqueConstraint when entries.Count == 0 => new UniqueConstraintException("Unique constraint violation", exception.InnerException),
×
25
            _ => null,
×
26
        };
64✔
27
    }
64✔
28
}
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