ParseException class
The text of an expression or template is not valid, so it cannot be parsed.
Thrown by parseExpression, before anything is evaluated, so parsing
at startup finds bad expressions early. Template structure errors (an
unclosed #{, an empty #{}, unbalanced brackets) are plain
ParseExceptions; errors inside an expression are
SpelParseExceptions with a SpelMessage.
// An `@Value`-style template missing its closing brace.
try {
parser.parseExpression('#{1 + 2', ParserContext.template);
} on ParseException catch (e) {
log.error(e.message); // No ending suffix '}' for expression starting ...
}
Spring (Java):
try {
parser.parseExpression("#{1 + 2", ParserContext.TEMPLATE_EXPRESSION);
} catch (ParseException ex) {
log.warn(ex.getMessage());
}
- Inheritance
-
- Object
- ExpressionException
- ParseException
Constructors
- ParseException(String simpleMessage, {String? expressionString, int position = -1, Object? cause})
-
Creates a parse error with
simpleMessage.
Properties
- cause → Object?
-
The error that caused this one (a converter's or an accessor's), or
null.finalinherited - expressionString → String?
-
The text of the failed expression, or
nullwhen unknown.finalinherited - hashCode → int
-
The hash code for this object.
no setterinherited
- message → String
-
The full message, with the expression and position; the same as
toDetailedString (Spring's
getMessage()).no setterinherited - position → int
-
The character offset in expressionString where the problem was
found, or -1 when unknown.
finalinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- simpleMessage → String
-
The reason alone, without the expression and position (Spring's
getSimpleMessage()), such asEL1044E: Unexpectedly ran out of input.finalinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toDetailedString(
) → String -
Expression [text] @position: message, or only simpleMessage when the expression is unknown (Spring'stoDetailedString()).inherited -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited