using FileFlows.Plugin;
using FileFlows.Plugin.Attributes;
namespace FileFlows.BasicNodes.Functions;
///
/// A flow element 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";
///
public override string CustomColor => "var(--error)";
///
/// Gets or sets the reason to fail the flow
///
[TextVariable(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)
{
string reason = args.ReplaceVariables(Reason ?? string.Empty, stripMissing: true);
if (string.IsNullOrWhiteSpace(reason) == false)
{
args.Logger.ILog("Failing flow: " + reason);
args.FailureReason = Reason;
}
else
{
args.Logger.ILog("Failing flow");
}
return -1;
}
}