< Summary - Envilder .NET SDK

Information
Class: Envilder.SsoSessionExpiredException
Assembly: Envilder
File(s): /home/runner/work/envilder/envilder/src/sdks/dotnet/SsoSessionExpiredException.cs
Tag: 427_29134414720
Line coverage
100%
Covered lines: 11
Uncovered lines: 0
Coverable lines: 11
Total lines: 46
Line coverage: 100%
Branch coverage
100%
Covered branches: 2
Total branches: 2
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%
.ctor(...)100%11100%
BuildMessage(...)100%22100%

File(s)

/home/runner/work/envilder/envilder/src/sdks/dotnet/SsoSessionExpiredException.cs

#LineLine coverage
 1namespace Envilder;
 2
 3using System;
 4
 5/// <summary>
 6/// Thrown when an AWS request fails because the SSO session used to resolve
 7/// credentials has expired or could not be loaded. Carries the AWS profile
 8/// name (when known) so callers can surface a targeted remediation hint.
 9/// </summary>
 10public class SsoSessionExpiredException : Exception
 11{
 12  /// <summary>
 13  /// Gets the AWS profile whose SSO session expired, or <c>null</c> when no
 14  /// profile was configured.
 15  /// </summary>
 16  public string? ProfileName { get; }
 17
 18  /// <summary>Initializes a new instance for the given AWS profile.</summary>
 19  /// <param name="profileName">The AWS profile whose SSO session expired, or <c>null</c>.</param>
 20  public SsoSessionExpiredException(string? profileName)
 121    : base(BuildMessage(profileName))
 22  {
 123    ProfileName = profileName;
 124  }
 25
 26  /// <summary>Initializes a new instance wrapping the underlying AWS exception.</summary>
 27  /// <param name="profileName">The AWS profile whose SSO session expired, or <c>null</c>.</param>
 28  /// <param name="innerException">The original AWS SDK exception.</param>
 29  public SsoSessionExpiredException(string? profileName, Exception innerException)
 130    : base(BuildMessage(profileName), innerException)
 31  {
 132    ProfileName = profileName;
 133  }
 34
 35  private static string BuildMessage(string? profileName)
 36  {
 137    if (string.IsNullOrWhiteSpace(profileName))
 38    {
 139      return "Your AWS SSO session has expired. Run 'aws sso login' " +
 140        "and re-run this command.";
 41    }
 42
 143    return $"Your AWS SSO session for profile '{profileName}' has expired. " +
 144      $"Run 'aws sso login --profile {profileName}' and re-run this command.";
 45  }
 46}