Class DefaultErrorHandlingStrategy
- java.lang.Object
-
- io.appform.hope.core.exceptions.errorstrategy.DefaultErrorHandlingStrategy
-
- All Implemented Interfaces:
ErrorHandlingStrategy
public class DefaultErrorHandlingStrategy extends Object implements ErrorHandlingStrategy
DefaultErrorHandlingStrategy. This will throw exceptions in case of errors.
-
-
Constructor Summary
Constructors Constructor Description DefaultErrorHandlingStrategy()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> ThandleIllegalEval(String message, T defaultValue)This handler is called in case there is some bug in the evaluation.<T> ThandleMissingValue(String path, T defaultValue)This handler is invoked when a value cannot be resolved from a path.<T> ThandleTypeMismatch(String path, String expected, String actual, T defaultValue)This handler is invoked when there is type mismatch between value at path and that present in json.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface io.appform.hope.core.exceptions.errorstrategy.ErrorHandlingStrategy
paramValidationFailure
-
-
-
-
Method Detail
-
handleMissingValue
public <T> T handleMissingValue(String path, T defaultValue)
This handler is invoked when a value cannot be resolved from a path. This happens when value is not present or null.- Specified by:
handleMissingValuein interfaceErrorHandlingStrategy- Type Parameters:
T- Type of default Value- Parameters:
path- Path for which value was not founddefaultValue- Default value to be returned if present- Returns:
- defaultValue or exception depending on implementation
-
handleTypeMismatch
public <T> T handleTypeMismatch(String path, String expected, String actual, T defaultValue)
This handler is invoked when there is type mismatch between value at path and that present in json.- Specified by:
handleTypeMismatchin interfaceErrorHandlingStrategy- Type Parameters:
T- Type of defaultValue- Parameters:
path- Path for which value mismatch was detectedexpected- Expected typeactual- Type found in provided jsondefaultValue- Default value to be returned in case of mismatch- Returns:
- defaultValue or throws exception depending on implementation
-
handleIllegalEval
public <T> T handleIllegalEval(String message, T defaultValue)
This handler is called in case there is some bug in the evaluation. This should never be raised faced in production. In case this happens it is a bug that should be reported.- Specified by:
handleIllegalEvalin interfaceErrorHandlingStrategy- Type Parameters:
T- Type of defaultValue- Parameters:
message- Custom message provided at assertion sitedefaultValue- Default value to be returned if this state is faced- Returns:
- defaultValue or throws exception depending on implementation
-
-