Class RuleCompilationException
java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
io.github.brantunger.unruly.api.exception.UnrulyException
io.github.brantunger.unruly.api.exception.RuleCompilationException
- All Implemented Interfaces:
Serializable
Exception thrown when a rule fails to compile, or when several do.
RulesEngine.load(java.util.List) compiles every rule before it throws,
so one exception reports everything that failed: failures() has one exception for each broken rule, for
a language that couldn't create its compiler and for each declared fact name the languages reject, and the name,
expression kind and issues of this exception are those of the first. A failure that isn't a rule's has no rule
name.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionRuleCompilationException(@Nullable String message) Constructs a new exception with the specified detail message.RuleCompilationException(@Nullable String message, @Nullable Throwable cause) Constructs a new exception with the specified detail message and cause.RuleCompilationException(@Nullable String message, @Nullable Throwable cause, @Nullable String ruleName) Constructs a new exception with the specified detail message, cause and the name of the rule that failed.RuleCompilationException(@Nullable String message, @Nullable Throwable cause, @Nullable String ruleName, @Nullable ExpressionKind expressionKind, List<InvalidExpressionException.Issue> issues) Constructs a new exception for one rule's condition or action.RuleCompilationException(@Nullable String message, List<RuleCompilationException> failures) Constructs an exception for several failures while loading a rule list. -
Method Summary
Modifier and TypeMethodDescriptionfailures()Returns every failure of the load, in the order they were found: each broken rule's, in priority order; a language that couldn't create its compiler, in place of the first rule that needed it; and each declared fact name the languages reject, last.@Nullable ExpressionKindReturns whether the rule's condition or its action failed.@Nullable StringReturns the name of the rule that failed, asRule.getRuleName()returns it.issues()Returns where and what the expression language found wrong, when it said.Methods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
-
Constructor Details
-
RuleCompilationException
Constructs a new exception with the specified detail message.- Parameters:
message- The detail message
-
RuleCompilationException
Constructs a new exception with the specified detail message and cause.- Parameters:
message- The detail messagecause- The cause
-
RuleCompilationException
public RuleCompilationException(@Nullable String message, @Nullable Throwable cause, @Nullable String ruleName) Constructs a new exception with the specified detail message, cause and the name of the rule that failed.- Parameters:
message- The detail messagecause- The causeruleName- The name of the rule that failed, ornullif the failure isn't about one rule or the rule has no name
-
RuleCompilationException
public RuleCompilationException(@Nullable String message, @Nullable Throwable cause, @Nullable String ruleName, @Nullable ExpressionKind expressionKind, List<InvalidExpressionException.Issue> issues) Constructs a new exception for one rule's condition or action.- Parameters:
message- The detail messagecause- The causeruleName- The name of the rule that failed, ornullif the rule has no nameexpressionKind- Whether the condition or the action failed, ornullif neither didissues- Where and what the expression language found wrong; copied- Throws:
NullPointerException- ifissuesor one of its elements isnull
-
RuleCompilationException
Constructs an exception for several failures while loading a rule list. Its rule name, expression kind and issues are those of the first failure, which is also its cause.- Parameters:
message- The detail messagefailures- Each failure, in the order they were found; copied- Throws:
IllegalArgumentException- iffailuresis emptyNullPointerException- iffailuresor one of its elements isnull
-
-
Method Details
-
getRuleName
Returns the name of the rule that failed, asRule.getRuleName()returns it. Unlike the message, it isn't escaped or shortened, so it can be used to look the rule up.- Returns:
- The rule's name, or
nullif the failure isn't about one rule (for example an expression language failed to create its compiler, or an element of the list isnull)
-
getExpressionKind
Returns whether the rule's condition or its action failed.- Returns:
- The kind of expression, or
nullif the failure isn't about a condition or an action, for example a rule written in a language the engine doesn't have
-
issues
Returns where and what the expression language found wrong, when it said.- Returns:
- The issues, possibly none; unmodifiable
-
failures
Returns every failure of the load, in the order they were found: each broken rule's, in priority order; a language that couldn't create its compiler, in place of the first rule that needed it; and each declared fact name the languages reject, last. Only a rule's failure has arule name.- Returns:
- One exception for each failure, or only this exception if there was one; unmodifiable
-