Class RuleError
java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
software.amazon.smithy.rulesengine.language.error.RuleError
- All Implemented Interfaces:
Serializable
An exception that can be thrown when a rule-set is invalid.
Used for providing meaningful contextual information when an invalid rule-set is encountered.
- See Also:
-
Nested Class Summary
-
Constructor Summary
ConstructorDescriptionRuleError
(SourceException root) Constructs a new RuleError from the source exception. -
Method Summary
Modifier and TypeMethodDescriptionstatic void
Evaluates the runnable and creates a RuleError with the provided context if there's an error.static void
context
(String message, FromSourceLocation sourceLocation, Runnable runnable) Evaluates the runnable and creates a RuleError with the provided context if there's an error.static <T> T
context
(String message, FromSourceLocation sourceLocation, RuleError.Evaluator<T> runnable) Evaluates the runnable and creates a RuleError with the provided context if there's an error.static <T> T
context
(String message, RuleError.Evaluator<T> runnable) Evaluates the runnable and creates a RuleError with the provided context if there's an error.toString()
withContext
(String context, SourceLocation location) Sets a piece of context on this error.Methods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace
-
Constructor Details
-
RuleError
Constructs a new RuleError from the source exception.- Parameters:
root
- the exception this rule error is based on.
-
-
Method Details
-
context
Evaluates the runnable and creates a RuleError with the provided context if there's an error.- Parameters:
message
- a message representing the context for this runnable statement's evaluation.runnable
- a runnable to evaluate a statement in the current context.
-
context
Evaluates the runnable and creates a RuleError with the provided context if there's an error.- Type Parameters:
T
- the type of the value returned by the runnable.- Parameters:
message
- a message representing the context for this runnable statement's evaluation.runnable
- a runnable to evaluate a statement in the current context.- Returns:
- the value returned by the runnable.
- Throws:
RuleError
- when the rule being evaluated in the context fails.
-
context
Evaluates the runnable and creates a RuleError with the provided context if there's an error.- Parameters:
message
- a message representing the context for this runnable statement's evaluation.sourceLocation
- the source location for this runnable statement's evaluation.runnable
- a runnable to evaluate a statement in the current context.
-
context
public static <T> T context(String message, FromSourceLocation sourceLocation, RuleError.Evaluator<T> runnable) throws RuleError Evaluates the runnable and creates a RuleError with the provided context if there's an error.- Type Parameters:
T
- the type of the value returned by the runnable.- Parameters:
message
- a message representing the context for this runnable statement's evaluation.sourceLocation
- the source location for this runnable statement's evaluation.runnable
- a runnable to evaluate a statement in the current context.- Returns:
- the value returned by the runnable.
- Throws:
RuleError
- when the rule being evaluated in the context fails.
-
withContext
Sets a piece of context on this error.- Parameters:
context
- the context to add to the error.location
- the source location of the context being added.- Returns:
- returns this error with the added context.
-
toString
-