< Summary

Information
Class: Elsa.Workflows.State.ExceptionState
Assembly: Elsa.Workflows.Core
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Core/State/ExceptionState.cs
Line coverage
100%
Covered lines: 17
Uncovered lines: 0
Coverable lines: 17
Total lines: 47
Line coverage: 100%
Branch coverage
100%
Covered branches: 6
Total branches: 6
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%
get_Type()100%11100%
get_Message()100%11100%
get_StackTrace()100%11100%
get_InnerException()100%11100%
get_Metadata()100%11100%
.ctor()100%11100%
FromException(...)100%66100%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Core/State/ExceptionState.cs

#LineLine coverage
 1using System.Text.Json.Serialization;
 2
 3// ReSharper disable NotAccessedPositionalProperty.Global
 4
 5namespace Elsa.Workflows.State;
 6
 7/// <summary>
 8/// A simplified, serializable model representing an exception.
 9/// </summary>
 4910public record ExceptionState(
 2811    Type Type,
 5412    string Message,
 2313    string? StackTrace,
 7314    ExceptionState? InnerException)
 15{
 16    /// <summary>
 17    /// Gets privacy-safe structured exception metadata.
 18    /// </summary>
 7919    public IReadOnlyDictionary<string, string>? Metadata { get; init; }
 20
 21    /// <summary>
 22    /// Constructor
 23    /// </summary>
 24    [JsonConstructor]
 125    public ExceptionState() : this(default!, default!, default, default)
 26    {
 27
 128    }
 29
 30    /// <summary>
 31    /// Creates a new <see cref="ExceptionState"/> from the specified exception.
 32    /// </summary>
 33    public static ExceptionState? FromException(Exception? ex)
 34    {
 350235        if (ex == null)
 345536            return null;
 37
 4738        var metadataProvider = ex as ISafeExceptionMetadataProvider;
 4739        var metadata = metadataProvider?.GetSafeMetadata();
 4740        var innerException = metadataProvider == null ? FromException(ex.InnerException) : null;
 41
 4742        return new ExceptionState(ex.GetType(), ex.Message, ex.StackTrace, innerException)
 4743        {
 4744            Metadata = metadata
 4745        };
 46    }
 47}