Skip to content

Commit b2e8967

Browse files
Update src/WorkflowCore.DSL/Services/DefinitionLoader.cs
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent d52d0eb commit b2e8967

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/WorkflowCore.DSL/Services/DefinitionLoader.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,18 @@ void primitiveAction(IStepBody pStep, object pData)
252252
if (stepProperty.PropertyType.IsAssignableFrom(primitiveValue.GetType()))
253253
stepProperty.SetValue(pStep, primitiveValue);
254254
else
255-
stepProperty.SetValue(pStep, System.Convert.ChangeType(primitiveValue, stepProperty.PropertyType));
255+
try
256+
{
257+
stepProperty.SetValue(pStep, System.Convert.ChangeType(primitiveValue, stepProperty.PropertyType));
258+
}
259+
catch (InvalidCastException ex)
260+
{
261+
throw new ArgumentException($"Failed to convert input '{input.Key}' for step '{source.Id}' to type '{stepProperty.PropertyType.Name}'.", ex);
262+
}
263+
catch (FormatException ex)
264+
{
265+
throw new ArgumentException($"Failed to convert input '{input.Key}' for step '{source.Id}' to type '{stepProperty.PropertyType.Name}'.", ex);
266+
}
256267
}
257268
step.Inputs.Add(new ActionParameter<IStepBody, object>(primitiveAction));
258269
continue;

0 commit comments

Comments
 (0)