Throw InputEvaluationException for input evaluation errors
Introduced `InputEvaluationException` to encapsulate errors during input evaluation in `ActivityExecutionContextExtensions`. Refactored the input evaluation logic by adding a core evaluation method to improve error handling and clarity.
This commit is contained in:
parent
b613ff6b61
commit
d4a2a5f03a
|
|
@ -0,0 +1,6 @@
|
|||
namespace Elsa.Workflows.Exceptions;
|
||||
|
||||
public class InputEvaluationException(string inputName, string message, Exception exception) : Exception(message, exception)
|
||||
{
|
||||
public string InputName { get; } = inputName;
|
||||
}
|
||||
|
|
@ -3,6 +3,7 @@ using Elsa.Expressions.Contracts;
|
|||
using Elsa.Expressions.Helpers;
|
||||
using Elsa.Expressions.Models;
|
||||
using Elsa.Workflows;
|
||||
using Elsa.Workflows.Exceptions;
|
||||
using Elsa.Workflows.Models;
|
||||
|
||||
// ReSharper disable once CheckNamespace
|
||||
|
|
@ -68,6 +69,18 @@ public static partial class ActivityExecutionContextExtensions
|
|||
}
|
||||
|
||||
private static async Task<object?> EvaluateInputPropertyAsync(this ActivityExecutionContext context, ActivityDescriptor activityDescriptor, InputDescriptor inputDescriptor)
|
||||
{
|
||||
try
|
||||
{
|
||||
return await EvaluateInputPropertyCoreAsync(context, activityDescriptor, inputDescriptor);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new InputEvaluationException(inputDescriptor.Name, $"Failed to evaluate activity input '{inputDescriptor.Name}'", e);
|
||||
}
|
||||
}
|
||||
|
||||
private static async Task<object?> EvaluateInputPropertyCoreAsync(this ActivityExecutionContext context, ActivityDescriptor activityDescriptor, InputDescriptor inputDescriptor)
|
||||
{
|
||||
var activity = context.Activity;
|
||||
var defaultValue = inputDescriptor.DefaultValue;
|
||||
|
|
|
|||
Loading…
Reference in a new issue