Class ExceptionResolvers
java.lang.Object
pro.verron.officestamper.preset.ExceptionResolvers
The ExceptionResolvers class provides a set of static factory methods to create different types of ExceptionResolver
implementations.
These resolvers are designed to handle exceptions that occur during the processing of placeholders in text
documents.
This class is a utility class and cannot be instantiated.
-
Method Summary
Modifier and TypeMethodDescriptionstatic ExceptionResolverThe defaulting resolver class will handle exceptions by returning an empty string.static ExceptionResolverdefaulting(String value) The defaulting resolver class will handle exceptions by returning a default value.static ExceptionResolverlegacyBehavior(boolean shouldFail, boolean emptyOnError, boolean shouldReplace, String replacementValue) Deprecated, for removal: This API element is subject to removal in a future version.This method is deprecated and scheduled for removal in future versions.static ExceptionResolverpassing()The passing resolver will handle exceptions by returning the placeholder expression.static ExceptionResolverthrowing()The throwing resolver will handle exceptions by immediately throwing an OfficeStamperException.
-
Method Details
-
passing
The passing resolver will handle exceptions by returning the placeholder expression. It logs the exception message and the stack trace if tracing is enabled.- Returns:
- An instance of
ExceptionResolverthat returns the placeholder expression.
-
defaulting
The defaulting resolver class will handle exceptions by returning an empty string. It logs the exception message and the stack trace if tracing is enabled.- Returns:
- An instance of
ExceptionResolverthat returns an empty string.
-
defaulting
The defaulting resolver class will handle exceptions by returning a default value. It logs the exception message and the stack trace if tracing is enabled.- Parameters:
value- The default value to be returned if an exception occurs.- Returns:
- An instance of
ExceptionResolverthat returns a default value.
-
throwing
The throwing resolver will handle exceptions by immediately throwing an OfficeStamperException. It is used to propagate errors encountered during the processing of placeholders in text documents.- Returns:
- An instance of
ExceptionResolverthat throws an exception.
-
legacyBehavior
@Deprecated(since="2.5", forRemoval=true) public static ExceptionResolver legacyBehavior(boolean shouldFail, boolean emptyOnError, boolean shouldReplace, String replacementValue) Deprecated, for removal: This API element is subject to removal in a future version.This method is deprecated and scheduled for removal in future versions. Use more specific factory methods instead.Provides a legacy behavior for creating an appropriateExceptionResolverbased on the input parameters.- Parameters:
shouldFail- iftrue, returns a resolver that throws an exception.emptyOnError- iftrue, returns a resolver that provides an empty string on error.shouldReplace- iftrue, returns a resolver that uses the specified replacement value.replacementValue- the replacement value to be used ifshouldReplaceistrue. This parameter is ignored ifshouldReplaceisfalse.- Returns:
- an
ExceptionResolverinstance that behaves according to the specified parameters.
-