Update ActivityNotFoundActivity to throw exception when executed

This commit is contained in:
Sipke Schoorstra 2023-10-26 14:54:21 +02:00
parent 2b34f1d72c
commit 591fdd670b
2 changed files with 31 additions and 0 deletions

View file

@ -1,6 +1,7 @@
using System.ComponentModel;
using System.Runtime.CompilerServices;
using Elsa.Workflows.Core.Attributes;
using Elsa.Workflows.Core.Exceptions;
using JetBrains.Annotations;
namespace Elsa.Workflows.Core.Activities;
@ -38,4 +39,10 @@ public class NotFoundActivity : CodeActivity
/// The original activity JSON.
/// </summary>
public string OriginalActivityJson { get; set; } = default!;
/// <inheritdoc />
protected override void Execute(ActivityExecutionContext context)
{
throw new ActivityNotFoundException(MissingTypeName, MissingTypeVersion);
}
}

View file

@ -0,0 +1,24 @@
namespace Elsa.Workflows.Core.Exceptions;
/// <summary>
/// Thrown when a NotFoundActivity is executed.
/// </summary>
public class ActivityNotFoundException : Exception
{
/// <inheritdoc />
public ActivityNotFoundException(string missingTypeName, int missingTypeVersion) : base($"Activity type '{missingTypeName}' version '{missingTypeVersion}' could not be found.")
{
MissingTypeName = missingTypeName;
MissingTypeVersion = missingTypeVersion;
}
/// <summary>
/// The type name of the missing activity type.
/// </summary>
public string MissingTypeName { get; }
/// <summary>
/// The version of the missing activity type.
/// </summary>
public int MissingTypeVersion { get; }
}