
Colorful, consistent error and panic reports with ANSI styling, causal-chain formatting, structured notes and suggestions, configurable hooks, frame filtering, and automated GitHub issue link generation.
Colorful, consistent, and well-formatted error and panic reports for Kotlin Multiplatform.
A faithful line-by-line transliteration of Jane Lusby's (@yaahc) color-eyre Rust crate.
In terminal applications, CLI utilities, and backend services, plain exception stack traces are often noisy, difficult to scan, and lacking in operational context. Diagnostic information such as causal chains, command outputs, suggestions, and relevant environment details is easily lost.
color-eyre-kotlin brings the beloved error reporting workflow of Rust's color-eyre crate to Kotlin Multiplatform:
owo-colors-kotlin.Throwable.chain()).owo-colors: Full ANSI styling with dark and light themes, completely customizable per UI component..note()), warnings (.warning()), suggestions (.suggestion()), or child errors (.error())..header("Title:") to cleanly format multi-line stdout, stderr, or configuration payloads while suppressing empty sections.Add color-eyre-kotlin to your commonMain dependencies:
kotlin {
sourceSets {
commonMain.dependencies {
implementation("io.github.kotlinmania:color-eyre-kotlin:0.1.0")
}
}
}[versions]
color-eyre = "0.1.0"
[libraries]
color-eyre = { module = "io.github.kotlinmania:color-eyre-kotlin", version.ref = "color-eyre" }kotlin {
sourceSets {
commonMain.dependencies {
implementation(libs.color.eyre)
}
}
}<dependency>
<groupId>io.github.kotlinmania</groupId>
<artifactId>color-eyre-kotlin</artifactId>
<version>0.1.0</version>
</dependency>To install the default error and panic report hooks at application startup, call install():
import io.github.kotlinmania.coloreyre.install
fun main() {
// Install default error and panic reporting hooks
install().getOrThrow()
// Application logic proceeds with color-eyre formatting enabled
}HookBuilder provides complete control over the reporting pipeline:
import io.github.kotlinmania.coloreyre.HookBuilder
import io.github.kotlinmania.coloreyre.Theme
fun configureErrorReporting() {
HookBuilder.new()
// Select dark or light theme, or supply a custom Theme
.theme(Theme.dark())
// Display environment variable guidance (e.g. RUST_BACKTRACE hints)
.displayEnvSection(true)
// Display source file/line location where the error occurred
.displayLocationSection(true)
// Install frame filters to omit noise from dependencies
.addDefaultFilters()
// Configure automated GitHub issue creation links
.issueUrl("https://github.com/my-org/my-project/issues/new")
.addIssueMetadata("Version", "1.0.0")
.addIssueMetadata("Target", "Kotlin Multiplatform")
.install()
.getOrThrow()
}You can attach contextual sections to error reports using the section extension functions from io.github.kotlinmania.coloreyre.section:
import io.github.kotlinmania.coloreyre.Handler
import io.github.kotlinmania.coloreyre.section.error
import io.github.kotlinmania.coloreyre.section.header
import io.github.kotlinmania.coloreyre.section.note
import io.github.kotlinmania.coloreyre.section.suggestion
import io.github.kotlinmania.coloreyre.section.warning
import io.github.kotlinmania.coloreyre.section.withSection
fun handleProcessFailure(handler: Handler, exitCode: Int, stdout: String, stderr: String) {
handler
.note("Configuration loaded from /etc/app/config.json")
.warning("Process exited with non-zero exit code: $exitCode")
.suggestion("Verify database credentials and network connectivity, then retry.")
// Attach multi-line command output with an indented header (omitted if body is empty)
.withSection {
stderr.trim().header("Stderr:")
}
.withSection {
stdout.trim().header("Stdout:")
}
}When rendered, the resulting report cleanly formats each section with distinct colorized labels:
Error: Failed to execute process
Location:
at src/commonMain/kotlin/com/example/Process.kt:42
Stderr:
Connection refused: port 5432 unreachable
Note: Configuration loaded from /etc/app/config.json
Warning: Process exited with non-zero exit code: 1
Suggestion: Verify database credentials and network connectivity, then retry.
IndentedSection ensures consistent indentation across all custom sections and automatically suppresses headers when content is blank:
import io.github.kotlinmania.coloreyre.section.header
val stdout = " "
val section = stdout.trim().header("Output:")
println(section.toString()) // Produces empty string — does not pollute the report!When an issueUrl is configured on HookBuilder, recoverable errors or panics can append an autogenerated link that opens a pre-filled GitHub issue in the user's browser:
HookBuilder.new()
.issueUrl("https://github.com/KotlinMania/color-eyre-kotlin/issues/new")
.addIssueMetadata("App Version", "0.1.0")
.addIssueMetadata("OS", "macOS")
.install()
.getOrThrow()The generated URL includes:
<details> blocks for backtraces and span traces.The Theme data class allows fine-grained control over colors and font styles:
import io.github.kotlinmania.coloreyre.Theme
import io.github.kotlinmania.owocolors.style
val customTheme = Theme.dark()
.file(style().cyan())
.lineNumber(style().yellow())
.error(style().brightRed().bold())
.helpInfoWarning(style().yellow().bold())
.helpInfoSuggestion(style().green())
.helpInfoNote(style().blue())
HookBuilder.new()
.theme(customTheme)
.install()
.getOrThrow()| Component / Function | Return Type | Description |
|---|---|---|
install() |
Result<Unit> |
Installs default panic and error report hooks. |
HookBuilder.new() |
HookBuilder |
Constructs a fluent builder for configuring hooks. |
HookBuilder.theme(Theme) |
HookBuilder |
Configures the visual theme for rendered reports. |
HookBuilder.displayEnvSection(Boolean) |
HookBuilder |
Toggles display of the environment variables advice section. |
HookBuilder.displayLocationSection(Boolean) |
HookBuilder |
Toggles display of the source location section. |
HookBuilder.issueUrl(String) |
HookBuilder |
Sets the target URL for GitHub issue generation. |
HookBuilder.addIssueMetadata(String, Any) |
HookBuilder |
Attaches key-value metadata to generated GitHub issues. |
HookBuilder.addDefaultFilters() |
HookBuilder |
Adds standard frame filters to remove internal noise. |
Handler.note(Any) |
Handler |
Attaches a styled note section to the report. |
Handler.warning(Any) |
Handler |
Attaches a styled warning section to the report. |
Handler.suggestion(Any) |
Handler |
Attaches a styled suggestion section to the report. |
Handler.error(Throwable) |
Handler |
Attaches an auxiliary error chain to the report. |
Handler.withSection(() -> Any) |
Handler |
Lazily evaluates and attaches a custom section. |
Any.header(Any) |
IndentedSection |
Wraps content with an indented header, omitted if content is blank. |
Throwable.chain() |
List<Throwable> |
Returns the complete causal chain from root to cause. |
color-eyre-kotlin is compiled and verified across all KotlinMania target platforms:
| Platform | Target Identifiers |
|---|---|
| JVM |
jvm (Java 21+ toolchain) |
| Android |
android (AAR, API 24+), androidNativeArm64, androidNativeX64
|
| Apple |
macosArm64, iosArm64, iosSimulatorArm64, iosX64, tvosArm64, tvosSimulatorArm64, watchosArm64, watchosDeviceArm64, watchosSimulatorArm64
|
| Linux |
linuxX64, linuxArm64
|
| Windows | mingwX64 |
| Web |
js (Browser & Node.js), wasmJs (Browser & Node.js), wasmWasi (WASI) |
color-eyre-kotlin is a direct transliteration of the color-eyre Rust crate.
eyre-rs contributors.All architectural design, formatting layout, and conceptual credit belong to Jane Lusby and the upstream eyre maintainers.
Dual-licensed under either of:
at your option, matching the upstream Rust crate license.
Colorful, consistent, and well-formatted error and panic reports for Kotlin Multiplatform.
A faithful line-by-line transliteration of Jane Lusby's (@yaahc) color-eyre Rust crate.
In terminal applications, CLI utilities, and backend services, plain exception stack traces are often noisy, difficult to scan, and lacking in operational context. Diagnostic information such as causal chains, command outputs, suggestions, and relevant environment details is easily lost.
color-eyre-kotlin brings the beloved error reporting workflow of Rust's color-eyre crate to Kotlin Multiplatform:
owo-colors-kotlin.Throwable.chain()).owo-colors: Full ANSI styling with dark and light themes, completely customizable per UI component..note()), warnings (.warning()), suggestions (.suggestion()), or child errors (.error())..header("Title:") to cleanly format multi-line stdout, stderr, or configuration payloads while suppressing empty sections.Add color-eyre-kotlin to your commonMain dependencies:
kotlin {
sourceSets {
commonMain.dependencies {
implementation("io.github.kotlinmania:color-eyre-kotlin:0.1.0")
}
}
}[versions]
color-eyre = "0.1.0"
[libraries]
color-eyre = { module = "io.github.kotlinmania:color-eyre-kotlin", version.ref = "color-eyre" }kotlin {
sourceSets {
commonMain.dependencies {
implementation(libs.color.eyre)
}
}
}<dependency>
<groupId>io.github.kotlinmania</groupId>
<artifactId>color-eyre-kotlin</artifactId>
<version>0.1.0</version>
</dependency>To install the default error and panic report hooks at application startup, call install():
import io.github.kotlinmania.coloreyre.install
fun main() {
// Install default error and panic reporting hooks
install().getOrThrow()
// Application logic proceeds with color-eyre formatting enabled
}HookBuilder provides complete control over the reporting pipeline:
import io.github.kotlinmania.coloreyre.HookBuilder
import io.github.kotlinmania.coloreyre.Theme
fun configureErrorReporting() {
HookBuilder.new()
// Select dark or light theme, or supply a custom Theme
.theme(Theme.dark())
// Display environment variable guidance (e.g. RUST_BACKTRACE hints)
.displayEnvSection(true)
// Display source file/line location where the error occurred
.displayLocationSection(true)
// Install frame filters to omit noise from dependencies
.addDefaultFilters()
// Configure automated GitHub issue creation links
.issueUrl("https://github.com/my-org/my-project/issues/new")
.addIssueMetadata("Version", "1.0.0")
.addIssueMetadata("Target", "Kotlin Multiplatform")
.install()
.getOrThrow()
}You can attach contextual sections to error reports using the section extension functions from io.github.kotlinmania.coloreyre.section:
import io.github.kotlinmania.coloreyre.Handler
import io.github.kotlinmania.coloreyre.section.error
import io.github.kotlinmania.coloreyre.section.header
import io.github.kotlinmania.coloreyre.section.note
import io.github.kotlinmania.coloreyre.section.suggestion
import io.github.kotlinmania.coloreyre.section.warning
import io.github.kotlinmania.coloreyre.section.withSection
fun handleProcessFailure(handler: Handler, exitCode: Int, stdout: String, stderr: String) {
handler
.note("Configuration loaded from /etc/app/config.json")
.warning("Process exited with non-zero exit code: $exitCode")
.suggestion("Verify database credentials and network connectivity, then retry.")
// Attach multi-line command output with an indented header (omitted if body is empty)
.withSection {
stderr.trim().header("Stderr:")
}
.withSection {
stdout.trim().header("Stdout:")
}
}When rendered, the resulting report cleanly formats each section with distinct colorized labels:
Error: Failed to execute process
Location:
at src/commonMain/kotlin/com/example/Process.kt:42
Stderr:
Connection refused: port 5432 unreachable
Note: Configuration loaded from /etc/app/config.json
Warning: Process exited with non-zero exit code: 1
Suggestion: Verify database credentials and network connectivity, then retry.
IndentedSection ensures consistent indentation across all custom sections and automatically suppresses headers when content is blank:
import io.github.kotlinmania.coloreyre.section.header
val stdout = " "
val section = stdout.trim().header("Output:")
println(section.toString()) // Produces empty string — does not pollute the report!When an issueUrl is configured on HookBuilder, recoverable errors or panics can append an autogenerated link that opens a pre-filled GitHub issue in the user's browser:
HookBuilder.new()
.issueUrl("https://github.com/KotlinMania/color-eyre-kotlin/issues/new")
.addIssueMetadata("App Version", "0.1.0")
.addIssueMetadata("OS", "macOS")
.install()
.getOrThrow()The generated URL includes:
<details> blocks for backtraces and span traces.The Theme data class allows fine-grained control over colors and font styles:
import io.github.kotlinmania.coloreyre.Theme
import io.github.kotlinmania.owocolors.style
val customTheme = Theme.dark()
.file(style().cyan())
.lineNumber(style().yellow())
.error(style().brightRed().bold())
.helpInfoWarning(style().yellow().bold())
.helpInfoSuggestion(style().green())
.helpInfoNote(style().blue())
HookBuilder.new()
.theme(customTheme)
.install()
.getOrThrow()| Component / Function | Return Type | Description |
|---|---|---|
install() |
Result<Unit> |
Installs default panic and error report hooks. |
HookBuilder.new() |
HookBuilder |
Constructs a fluent builder for configuring hooks. |
HookBuilder.theme(Theme) |
HookBuilder |
Configures the visual theme for rendered reports. |
HookBuilder.displayEnvSection(Boolean) |
HookBuilder |
Toggles display of the environment variables advice section. |
HookBuilder.displayLocationSection(Boolean) |
HookBuilder |
Toggles display of the source location section. |
HookBuilder.issueUrl(String) |
HookBuilder |
Sets the target URL for GitHub issue generation. |
HookBuilder.addIssueMetadata(String, Any) |
HookBuilder |
Attaches key-value metadata to generated GitHub issues. |
HookBuilder.addDefaultFilters() |
HookBuilder |
Adds standard frame filters to remove internal noise. |
Handler.note(Any) |
Handler |
Attaches a styled note section to the report. |
Handler.warning(Any) |
Handler |
Attaches a styled warning section to the report. |
Handler.suggestion(Any) |
Handler |
Attaches a styled suggestion section to the report. |
Handler.error(Throwable) |
Handler |
Attaches an auxiliary error chain to the report. |
Handler.withSection(() -> Any) |
Handler |
Lazily evaluates and attaches a custom section. |
Any.header(Any) |
IndentedSection |
Wraps content with an indented header, omitted if content is blank. |
Throwable.chain() |
List<Throwable> |
Returns the complete causal chain from root to cause. |
color-eyre-kotlin is compiled and verified across all KotlinMania target platforms:
| Platform | Target Identifiers |
|---|---|
| JVM |
jvm (Java 21+ toolchain) |
| Android |
android (AAR, API 24+), androidNativeArm64, androidNativeX64
|
| Apple |
macosArm64, iosArm64, iosSimulatorArm64, iosX64, tvosArm64, tvosSimulatorArm64, watchosArm64, watchosDeviceArm64, watchosSimulatorArm64
|
| Linux |
linuxX64, linuxArm64
|
| Windows | mingwX64 |
| Web |
js (Browser & Node.js), wasmJs (Browser & Node.js), wasmWasi (WASI) |
color-eyre-kotlin is a direct transliteration of the color-eyre Rust crate.
eyre-rs contributors.All architectural design, formatting layout, and conceptual credit belong to Jane Lusby and the upstream eyre maintainers.
Dual-licensed under either of:
at your option, matching the upstream Rust crate license.