From 591fdd670bee2443ea6c366dfc7c8878e8c1cabc Mon Sep 17 00:00:00 2001 From: Sipke Schoorstra Date: Thu, 26 Oct 2023 14:54:21 +0200 Subject: [PATCH] Update ActivityNotFoundActivity to throw exception when executed --- .../Activities/NotFoundActivity.cs | 7 ++++++ .../Exceptions/ActivityNotFoundException.cs | 24 +++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 src/modules/Elsa.Workflows.Core/Exceptions/ActivityNotFoundException.cs diff --git a/src/modules/Elsa.Workflows.Core/Activities/NotFoundActivity.cs b/src/modules/Elsa.Workflows.Core/Activities/NotFoundActivity.cs index 42cc12550..c3bba3ba7 100644 --- a/src/modules/Elsa.Workflows.Core/Activities/NotFoundActivity.cs +++ b/src/modules/Elsa.Workflows.Core/Activities/NotFoundActivity.cs @@ -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. /// public string OriginalActivityJson { get; set; } = default!; + + /// + protected override void Execute(ActivityExecutionContext context) + { + throw new ActivityNotFoundException(MissingTypeName, MissingTypeVersion); + } } \ No newline at end of file diff --git a/src/modules/Elsa.Workflows.Core/Exceptions/ActivityNotFoundException.cs b/src/modules/Elsa.Workflows.Core/Exceptions/ActivityNotFoundException.cs new file mode 100644 index 000000000..bc3751bca --- /dev/null +++ b/src/modules/Elsa.Workflows.Core/Exceptions/ActivityNotFoundException.cs @@ -0,0 +1,24 @@ +namespace Elsa.Workflows.Core.Exceptions; + +/// +/// Thrown when a NotFoundActivity is executed. +/// +public class ActivityNotFoundException : Exception +{ + /// + public ActivityNotFoundException(string missingTypeName, int missingTypeVersion) : base($"Activity type '{missingTypeName}' version '{missingTypeVersion}' could not be found.") + { + MissingTypeName = missingTypeName; + MissingTypeVersion = missingTypeVersion; + } + + /// + /// The type name of the missing activity type. + /// + public string MissingTypeName { get; } + + /// + /// The version of the missing activity type. + /// + public int MissingTypeVersion { get; } +} \ No newline at end of file