ConfigError

sealed class ConfigError

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

path

Dot-separated path to the offending field (e.g. "database.port").

message

Human-readable description of the error, auto-generated by each subclass.

See also

Inheritors

Types

Link copied to clipboard
object Companion

Companion providing shared formatting utilities for error message construction.

Link copied to clipboard
class InvalidValue(val path: String, val raw: Any?, val expected: String, val hint: String? = null) : ConfigError

A value was present but could not be converted to the expected type.

Link copied to clipboard
class MissingRequired(val path: String, val expected: String) : ConfigError

A required field (non-nullable, no default) is missing from the YAML map.

Link copied to clipboard
class OutOfRange(val path: String, val raw: Number, val min: Double, val max: Double, val fellBackTo: Any? = null) : ConfigError

A numeric value violates the bounds declared by the @Range annotation.

Link copied to clipboard
class PatternMismatch(val path: String, val raw: String, val pattern: String, val description: String? = null) : ConfigError

A string value does not match the regex declared by the @Pattern annotation.

Link copied to clipboard
class UnknownKey(val path: String, val suggestion: String? = null) : ConfigError

A key in the YAML map does not correspond to any constructor parameter of the target data class.

Link copied to clipboard
class UnknownType(val path: String, val typeName: String, val rawSection: Map<String, Any?>? = null) : ConfigError

No serializer is registered for the requested type.

Properties

Link copied to clipboard
Link copied to clipboard