← Back to API Reference

Exceptions

All RoslynRules exceptions inherit from RulesException.

public abstract class RulesException : Exception

Exception Hierarchy

Exception When Thrown
RuleValidationException Rule has no Expression, Action, or active children
CircularReferenceException Circular reference in the child rule tree (extends RuleValidationException)
SyntaxErrorException Invalid C# syntax in expression or action (extends RuleValidationException)
RuleCompilationException Roslyn compilation failure
NotCompiledException Execute called before Compile (extends RuleCompilationException)
RuleTimeoutException Rule exceeded configured Timeout
WorkflowException Workflow has no active rules
DuplicateRuleIdException Duplicate rule IDs in same workflow (extends WorkflowException)
AotCompatibilityException A JIT-only API was called in an AOT/trimming environment

ValidationError

Non-throwing validation uses ValidationError:

public record ValidationError(string Message, ValidationErrorType ErrorType, Guid? RuleId = null, string? RuleDescription = null);

Error types:

Type When
NoActiveRules Workflow has no active rules
EmptyRule Rule has no Expression, Action, or active children
CircularReference Circular dependency detected
SyntaxError Invalid C# syntax
DuplicateRuleId Duplicate rule IDs
MissingDependency DependsOnRuleId points to non-existent rule
General Other validation failure

Usage

var compileParams = new[] { new RuleParameter("customer", typeof(Customer)) };
var executeParams = new[] { new RuleParameter("customer", typeof(Customer), customer) };

try
{
    workflow.Validate();
    workflow.Compile(compileParams);
    var results = workflow.Execute(executeParams);
}
catch (SyntaxErrorException ex)
{
    Console.WriteLine($"Syntax error: {ex.Message}");
}
catch (CircularReferenceException ex)
{
    Console.WriteLine($"Circular ref at rule {ex.RuleId}");
}
catch (RulesException ex)  // Catch-all for any rules error
{
    Console.WriteLine($"Rules error: {ex.Message}");
}


Back to top

MIT License. Built with Roslyn + Typed Delegates.