Module error

Module error 

Source
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§

BuildError
Build process errors.
CliError
Top-level CLI error type.
ConfigError
Configuration-specific errors.

Traits§

ResultExt
Extension trait for adding context to Result types.

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 CliError as the default error type.