< Summary - Envilder .NET SDK

Information
Class: Envilder.ContractValidationException
Assembly: Envilder
File(s): /home/runner/work/envilder/envilder/src/sdks/dotnet/Application/ContractValidationException.cs
Tag: 605_44106794472
Line coverage
100%
Covered lines: 14
Uncovered lines: 0
Coverable lines: 14
Total lines: 41
Line coverage: 100%
Branch coverage
100%
Covered branches: 8
Total branches: 8
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%11100%
BuildMessage(...)100%88100%

File(s)

/home/runner/work/envilder/envilder/src/sdks/dotnet/Application/ContractValidationException.cs

#LineLine coverage
 1namespace Envilder;
 2
 3using System;
 4using System.Linq;
 5
 6/// <summary>
 7/// Thrown by a load with contract validation enabled when the map file is
 8/// invalid or a declared secret cannot be confirmed. The message names the
 9/// failing keys and paths, never a secret value.
 10/// </summary>
 11public class ContractValidationException : Exception
 12{
 13  /// <summary>Initializes a new instance for the check that failed.</summary>
 14  /// <param name="result">The full outcome of the check.</param>
 15  public ContractValidationException(ContractValidationResult result)
 116    : base(BuildMessage(result))
 17  {
 118    Result = result;
 119  }
 20
 21  /// <summary>The full outcome of the check that failed.</summary>
 22  public ContractValidationResult Result { get; }
 23
 24  private static string BuildMessage(ContractValidationResult result)
 25  {
 126    if (result.MapFileErrors.Count > 0)
 27    {
 128      var errors = string.Join(
 129        "; ",
 130        result.MapFileErrors.Select(error => $"{error.Key}: {error.Message}"));
 131      return $"Map file contract validation failed: {errors}";
 32    }
 33
 134    var keys = string.Join(
 135      ", ",
 136      result.Keys
 137        .Where(key => key.Status != SecretExistenceStatus.Exists)
 138        .Select(key => $"{key.Variable} ({key.Path}): {key.Status.ToWireValue()}"));
 139    return $"Map file contract validation failed: {keys}";
 40  }
 41}