ConfigErrorCollector

Mutable accumulator for ConfigError instances generated during deserialization and validation.

A single collector is threaded through the entire Deserializer call tree so that errors from nested data classes, collections, and annotation validators are gathered into one place. After deserialization completes, the caller inspects the collector to decide whether to use the (potentially partial) result or to abort.

Typical usage:

val errors = ConfigErrorCollector()
val config = deserializer.deserialize(MyConfig::class, yamlMap, errors)

if (errors.hasErrors()) {
println(ConfigErrorFormatter().format(errors.all(), "my-service"))
} else {
startService(config!!)
}

The collector is not thread-safe; it is intended to be used within a single deserialization pass.

Since

1.0

See also

Constructors

Link copied to clipboard
constructor()

Properties

Link copied to clipboard
val size: Int

The number of errors currently recorded.

Functions

Link copied to clipboard
fun add(error: ConfigError)

Appends a ConfigError to this collector.

Link copied to clipboard

Returns a snapshot (defensive copy) of all recorded errors.

Link copied to clipboard
fun clear()

Removes all previously recorded errors, resetting this collector to its initial state.

Link copied to clipboard

Returns true if at least one error has been recorded.