Expand description
Comprehensive error handling for the Joy CLI.
This module provides a hierarchical error type system using thiserror for
structured error handling with excellent error messages. Each error variant
is designed to be actionable and provide context to help users resolve issues.
§Architecture
The error hierarchy follows these principles:
- Top-level errors (
CliError) represent broad categories of failures - Domain-specific errors (
ConfigError,BuildError) provide detailed context - Error conversion is automatic via
#[from]attributes - Context helpers allow attaching additional information to errors
§Example
use fob_cli::error::{Result, ResultExt, CliError};
use std::path::Path;
use std::str::FromStr;
struct Config;
impl FromStr for Config {
type Err = CliError;
fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
Ok(Config)
}
}
fn load_config(path: &Path) -> Result<Config> {
std::fs::read_to_string(path)
.with_path(path)?
.parse()
.with_hint("Check JSON syntax")
}Enums§
- Build
Error - Build process errors.
- CliError
- Top-level CLI error type.
- Config
Error - Configuration-specific errors.
Traits§
- Result
Ext - Extension trait for adding context to
Resulttypes.
Functions§
- bundler_
error_ to_ miette - Convert fob-bundler Error to miette Report
- cli_
error_ to_ miette - Convert CliError to miette Report
Type Aliases§
- Result
- Result type alias using
CliErroras the default error type.