Skip to main content

format_error_chain

Function format_error_chain 

Source
pub fn format_error_chain<E>(error: &ComposableError<E>) -> String
where E: Display,
Expand description

Formats an error with its full context chain.

This function creates a human-readable string representation of an error and all its context information, formatted as a chain from most recent context to core error.

§Type Parameters

  • E: The error type (must implement Display)

§Arguments

  • error: The ComposableError to format

§Examples

use rustica::error::{ComposableError, format_error_chain};

let error = ComposableError::new("file not found")
    .with_context("failed to load config".to_string())
    .with_context("application startup failed".to_string());

let formatted = format_error_chain(&error);
assert!(formatted.contains("application startup failed"));
assert!(formatted.contains("failed to load config"));
assert!(formatted.contains("file not found"));