ExpressionException class

The common supertype of everything that can go wrong with an expression: invalid text (ParseException) or a failed evaluation (EvaluationException).

Catch it where an expression comes from configuration or a user and a bad one should be reported rather than crash the caller. message says which expression failed and where (Expression [1 +] @3: ...); simpleMessage is the bare reason. Exceptions thrown by methods and constructors the expression calls are not wrapped in it (those of registered functions are, as EL1023E).

// A rule typed by an administrator: report it, keep running.
try {
  SpelExpressionParser().parseExpression(input).getValue(context);
} on ExpressionException catch (e) {
  log.warning(e.message); // Expression [1 +] @3: EL1044E: Unexpectedly ...
}

Spring (Java):

try {
  parser.parseExpression(input).getValue(context);
} catch (ExpressionException ex) {
  log.warn(ex.getMessage());
}
Implemented types

Constructors

ExpressionException(String simpleMessage, {String? expressionString, int position = -1, Object? cause})
Creates an exception with simpleMessage, optionally pointing at position in expressionString and wrapping cause.

Properties

cause → Object?
The error that caused this one (a converter's or an accessor's), or null.
final
expressionString → String?
The text of the failed expression, or null when unknown.
final
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 setter
position → int
The character offset in expressionString where the problem was found, or -1 when unknown.
final
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 as EL1044E: Unexpectedly ran out of input.
final

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's toDetailedString()).
toString() → String
A string representation of this object.
override

Operators

operator ==(Object other) → bool
The equality operator.
inherited