using FileFlows.Plugin;
using FileFlows.Plugin.Attributes;
namespace FileFlows.BasicNodes.Functions;
///
/// A node that simply fails a flow
///
public class FailFlow : Node
{
///
/// Gets the number of input nodes
///
public override int Inputs => 1;
///
/// Gets the type of node
///
public override FlowElementType Type => FlowElementType.Logic;
///
/// Gets the icon of the flow
///
public override string Icon => "fas fa-exclamation-triangle";
///
/// Gets the URL for the help page
///
public override string HelpUrl => "https://fileflows.com/docs/plugins/basic-nodes/fail-flow";
///
/// Gets or sets the reason to fail the flow
///
[Text(1)]
public string Reason { get; set; }
///
/// Executes the node
///
/// the node parameters
/// -1 to indicate the flow should fail
public override int Execute(NodeParameters args)
{
if (string.IsNullOrWhiteSpace(Reason) == false)
{
args.Logger.ILog("Failing flow: " + Reason);
args.FailureReason = Reason;
}
else
{
args.Logger.ILog("Failing flow");
}
return -1;
}
}