Config Error
Sealed hierarchy representing all configuration errors that can occur during deserialization, validation, and key resolution.
Each subclass captures a specific category of error along with contextual information (path, raw value, expectation) that enables precise diagnostic messages. Errors are accumulated by ConfigErrorCollector and rendered by ConfigErrorFormatter.
Example of inspecting errors by type:
val errors: List<ConfigError> = collector.all()
errors.forEach { error ->
when (error) {
is ConfigError.InvalidValue -> println("Bad value at ${error.path}")
is ConfigError.UnknownKey -> println("Typo? ${error.suggestion}")
is ConfigError.OutOfRange -> println("${error.raw} not in [${error.min}, ${error.max}]")
is ConfigError.PatternMismatch -> println("Regex failed at ${error.path}")
is ConfigError.MissingRequired -> println("Missing: ${error.path}")
is ConfigError.UnknownType -> println("No serializer for ${error.typeName}")
}
}Since
1.0
Parameters
Dot-separated path to the offending field (e.g. "database.port").
Human-readable description of the error, auto-generated by each subclass.
See also
Inheritors
Types
A value was present but could not be converted to the expected type.
A required field (non-nullable, no default) is missing from the YAML map.
A numeric value violates the bounds declared by the @Range annotation.
A string value does not match the regex declared by the @Pattern annotation.
A key in the YAML map does not correspond to any constructor parameter of the target data class.
No serializer is registered for the requested type.