ConfigErrorFormatter

class ConfigErrorFormatter(useColors: Boolean = true)

Renders a list of ConfigError instances into a human-readable, optionally ANSI-colored report.

Errors are grouped by their concrete type (e.g. InvalidValue, UnknownKey) and printed with their dot-separated paths highlighted. A trailing summary line counts how many fields fell back to default values due to ConfigError.OutOfRange or ConfigError.PatternMismatch.

Example output (with colors disabled for illustration):

3 config error(s) found in my-service:

[InvalidValue]
server.port: Invalid value 'abc', expected Int

[UnknownKey]
databse: Unknown key 'databse' - did you mean 'database'?

[OutOfRange]
server.maxThreads: Value 9999 is out of range [1.0, 512.0], fell back to 16

1 field(s) fell back to default values.

Usage:

val formatter = ConfigErrorFormatter(useColors = true)
val report = formatter.format(collector.all(), configName = "my-service")
System.err.print(report)

Since

1.0

Parameters

useColors

When true (default), wraps error categories, paths, and summaries in ANSI escape codes. Set to false for log files or non-terminal output.

See also

Constructors

Link copied to clipboard
constructor(useColors: Boolean = true)

Types

Link copied to clipboard
object Companion

ANSI escape code constants used for terminal coloring.

Functions

Link copied to clipboard
fun format(errors: List<ConfigError>, configName: String = "config"): String

Formats the given list of errors into a multi-line diagnostic report.