< Summary

Information
Class: Elsa.Workflows.Activities.Fault
Assembly: Elsa.Workflows.Core
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Core/Activities/Fault.cs
Line coverage
100%
Covered lines: 18
Uncovered lines: 0
Coverable lines: 18
Total lines: 73
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%
Create(...)100%11100%
get_Code()100%11100%
get_Category()100%11100%
get_FaultType()100%11100%
get_Message()100%11100%
Execute(...)100%66100%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Core/Activities/Fault.cs

#LineLine coverage
 1using System.Runtime.CompilerServices;
 2using Elsa.Extensions;
 3using Elsa.Workflows.Attributes;
 4using Elsa.Workflows.Exceptions;
 5using Elsa.Workflows.Models;
 6using JetBrains.Annotations;
 7// ReSharper disable ExplicitCallerInfoArgument
 8
 9namespace Elsa.Workflows.Activities;
 10
 11/// <summary>
 12/// Faults the workflow.
 13/// </summary>
 14[Activity("Elsa", "Primitives", "Faults the workflow.")]
 15[PublicAPI]
 16public class Fault : Activity
 17{
 18    /// <inheritdoc />
 10619    public Fault([CallerFilePath] string? source = null, [CallerLineNumber] int? line = null) : base(source, line)
 20    {
 10621    }
 22
 23    /// <summary>
 24    /// Creates a fault activity.
 25    /// </summary>
 26    public static Fault Create(string code, string category, string type, string? message = null, [CallerFilePath] strin
 27    {
 1728        return new(source, line)
 1729        {
 1730            Code = new(code),
 1731            Message = new(message),
 1732            Category = new(category),
 1733            FaultType = new(type)
 1734        };
 35    }
 36
 37    /// <summary>
 38    /// Code to categorize the fault.
 39    /// </summary>
 40    [Input(Description = "Code to categorize the fault.")]
 35341    public Input<string> Code { get; set; } = null!;
 42
 43    /// <summary>
 44    /// Category to categorize the fault. Examples: HTTP, Alteration, Azure, etc.
 45    /// </summary>
 46    [Input(Description = "Category to categorize the fault. Examples: HTTP, Alteration, Azure, etc.")]
 35347    public Input<string> Category { get; set; } = null!;
 48
 49    /// <summary>
 50    /// The type of fault. Examples: System, Business, Integration, etc.
 51    /// </summary>
 52    [Input(
 53        DisplayName = "Type",
 54        Description = "The type of fault. Examples: System, Business, Integration, etc."
 55        )]
 35356    public Input<string> FaultType { get; set; } = null!;
 57
 58    /// <summary>
 59    /// The message to include with the fault.
 60    /// </summary>
 61    [Input(Description = "The message to include with the fault.")]
 38862    public Input<string?> Message { get; set; } = null!;
 63
 64    /// <inheritdoc />
 65    protected override void Execute(ActivityExecutionContext context)
 66    {
 1867        var code = Code.GetOrDefault(context) ?? "0";
 1868        var category = Category.GetOrDefault(context) ?? "General";
 1869        var type = FaultType.GetOrDefault(context) ?? "System";
 1870        var message = Message.GetOrDefault(context);
 1871        throw new FaultException(code, category, type, message);
 72    }
 73}