< Summary

Information
Class: Elsa.Persistence.EFCore.PostgreSql.Handlers.DbExceptionTransformer
Assembly: Elsa.Persistence.EFCore.PostgreSql
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Persistence.EFCore.PostgreSql/Handlers/DbExceptionTransformer.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 4
Coverable lines: 4
Total lines: 22
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 4
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
HandleAsync(...)0%2040%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Persistence.EFCore.PostgreSql/Handlers/DbExceptionTransformer.cs

#LineLine coverage
 1using Elsa.Workflows.Exceptions;
 2using JetBrains.Annotations;
 3using Npgsql;
 4
 5namespace Elsa.Persistence.EFCore.PostgreSql.Handlers;
 6
 7/// <summary>
 8/// Transforms database exceptions encountered when using a postgreSQL database into more generic exceptions.
 9/// </summary>
 10[UsedImplicitly]
 11public class DbExceptionTransformer : IDbExceptionHandler
 12{
 13    public Task HandleAsync(DbUpdateExceptionContext context)
 14    {
 015        var exception = context.Exception;
 16
 017        if (exception.InnerException is PostgresException { SqlState: "23505" })
 018            throw new UniqueKeyConstraintViolationException("Unable to save data", exception);
 19
 020        throw new DataProcessingException("Unable to save data", exception);
 21    }
 22}