Expand description
§Charon Error
Structured error handling for Rust with rich error reports, data sensitivity labels, panic capture, and GitLab issue integration.
Named after Charon, the Greek ferryman of the dead across the river Styx — this crate ferries your program from a running state to a graceful death, collecting every detail along the way.
§Features
- Error chains: Stack multiple errors with
ErrorReportto preserve full context - Sensitivity labels: Tag data as
Public,Private,Internal, orConfidentialto control what gets shared - Panic hooks: Capture panics and display human-readable reports with
setup_panic!andsetup_panic_simple! - Issue submission: Generate pre-filled GitLab issue URLs from errors via
GitLabErrorReport - Tracing integration: Works with the
tracingcrate - use#[instrument]andtracing::error!()alongsideErrorReport - Flexible formatting: Configure output detail with
ErrorFmtSettings
§Quick Start
use charon_error::prelude::*;
#[derive(Debug, ThisError)]
enum AppError {
#[error("failed to load config")]
ConfigLoad,
}
fn load_config() -> ResultER<String> {
std::fs::read_to_string("config.toml")
.change_context(AppError::ConfigLoad)?;
Ok("loaded".to_owned())
}§Using ResultER<T>
ResultER<T> is a type alias for Result<T, ErrorReport>. Use it as your
return type and the ResultExt trait methods become available on any
Result or Option:
use charon_error::prelude::*;
fn example() -> ResultER<()> {
let value: i32 = "not_a_number"
.parse::<i32>()
.change_context(StringError::new("parsing failed"))?;
Ok(())
}Modules§
- prelude
- Prelude module for convenient imports.
Macros§
- format_
string - Create an
ErrorFormatObj::FormatStringfrom multiple values. - map
- Create an
IndexMapwith string keys from key-value pairs. - setup_
panic - Set up a custom panic hook with issue submission and known-error matching.
- setup_
panic_ simple - Set up a simple panic hook that prints a human-readable error message.
Structs§
- Error
FmtSettings - Configuration for error formatting output.
- Error
Frame - A single frame in an error chain, capturing one error with its full context.
- Error
Report - The core error type that collects a chain of
ErrorFrames. - GitLabER
Global Settings - Global configuration for GitLab issue submission.
- GitLab
Error Report - GitLab implementation of
SubmitErrorReport. - Source
Location - Captures a source code location (file, line, column).
- String
Error - A simple error type that wraps a string message.
Enums§
- Error
Attachment - Data that can be attached to an
ErrorFramefor additional diagnostics. - Error
FmtLoD - Level of detail for error formatting output.
- Error
Format Obj - An intermediate representation for structured error output.
- Error
Sensitivity Label - Controls the visibility and handling of data based on its sensitivity.
- Filter
Object Error - Error returned when filtering object fields with a key that does not exist.
- Indentation
Style - Indentation style for formatted output.
- Link
Debug Ide - Format for source location links in terminal output.
Traits§
- Error
Fmt - Trait for converting error types into a structured
ErrorFormatObjtree. - Result
Ext - Extension trait for
ResultandOptionthat integrates withErrorReport. - Submit
Error Report - Trait for converting an
ErrorReportinto a submittable issue report.
Type Aliases§
- ResultER
- Convenience type alias for
Result<T, ErrorReport>.