Interface ConfigReferenceErrorHandler
- All Known Implementing Classes:
DefaultConfigReferenceErrorHandler
public interface ConfigReferenceErrorHandler
This interface work like a handler for errors that occur during config reference resolution and allows customization of how reference resolution errors are handled.
Users can provide their own implementation to customize error handling behavior (e.g. throwing exceptions for all errors, logging to a different system, etc...).
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionvoidonCircularReference(@NotNull ConfigCircularReferenceContext context) Called when a circular reference is detected during resolution.@Nullable ObjectonReferenceNotFound(@NotNull ConfigReferenceNotFoundContext context) Called when a reference cannot be resolved because the target config, folder config, item, or path was not found.@Nullable ObjectonTypeMismatch(@NotNull ConfigTypeMismatchContext context) Called when a resolved reference value cannot be coerced into the scalar or primitive type expected by the target field (for example, a non-numeric resolved value bound to anintfield).
-
Method Details
-
onReferenceNotFound
@Nullable @Nullable Object onReferenceNotFound(@NotNull @NotNull ConfigReferenceNotFoundContext context) Called when a reference cannot be resolved because the target config, folder config, item, or path was not found.- Parameters:
context- context information about the error- Returns:
- a fallback value to use (typically null), or throw an exception
-
onCircularReference
Called when a circular reference is detected during resolution.This method should typically throw an exception as circular references cannot be resolved. Returning normally is allowed but may lead to incomplete resolution.
- Parameters:
context- context information about the cycle
-
onTypeMismatch
Called when a resolved reference value cannot be coerced into the scalar or primitive type expected by the target field (for example, a non-numeric resolved value bound to anintfield).The returned value is used in place of the resolved value (typically
null, which binds the field to its default); the binder will then bind/coerce that fallback as usual. Implementations may also throw to abort binding.- Parameters:
context- context information about the type mismatch- Returns:
- a fallback value to use (typically null), or throw an exception
-