PlaceholderResolutionException class final
The error for a ${...} placeholder that has no value and no default,
or that refers to itself in a loop (a=${b}, b=${a}).
It is thrown wherever a value must be complete: @Value(r'${key}'),
reading a property whose value holds such a placeholder, and
resolveRequiredPlaceholders. During startup it fails the start, and
the message names the placeholder and the chain of values it was found
in. Catch it only where text comes from users or from outside, such as
a template with placeholders.
// A mail template edited by the shop owner may name unknown keys.
try {
return environment.resolveRequiredPlaceholders(template);
} on PlaceholderResolutionException catch (error) {
log.warn('Template uses ${error.placeholder}, which is not set');
return environment.resolvePlaceholders(template);
}
Spring (Java):
try {
return environment.resolveRequiredPlaceholders(template);
} catch (PlaceholderResolutionException ex) {
log.warn(ex.getMessage());
return environment.resolvePlaceholders(template);
}
The class is Spring 6.2's.
- Implemented types
Constructors
-
PlaceholderResolutionException(String reason, String placeholder, List<
String> values) -
Creates the exception for
placeholder, which failed because ofreasonwhilevalueswere being resolved.
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- message → String
-
The full message: reason followed by the chain of values, such
as
Could not resolve placeholder 'b' in value "${b}" <-- "a"when the propertyaholds${b}.no setter - placeholder → String
-
The key of the placeholder that failed, such as
db.url.final - reason → String
-
Why resolution failed, such as
Could not resolve placeholder 'db.url'orCircular placeholder reference 'a'.final - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
values
→ List<
String> -
The chain that led to the failure: the text the placeholder was in,
and the keys (or texts) resolved on the way there. message shows
it.
final
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited