Skip to content

Yoshi is a comprehensive error-handling framework designed for critical Rust applications that require detailed error diagnostics, structured error categorization, and high-performance error propagation.

License

Unknown and 2 other licenses found

Licenses found

Unknown
LICENSE
Unknown
LICENSE-APACHE
MIT
LICENSE-MIT
Notifications You must be signed in to change notification settings

arcmoonstudios/yoshi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

71 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Yoshi Error Handling Framework

Yoshi Logo

Crates.io Docs.rs Rust Version License: MIT OR Apache-2.0

A structured error handling framework for Rust that tells you what went wrong, where, and how to fix it.

What is Yoshi?

Yoshi provides rich, structured errors with context and metadata instead of generic "something broke" messages. It combines the ergonomics of anyhow with the type safety of thiserror, while adding powerful features like error categorization, suggestions, and metadata.

Quick Start

[dependencies]
yoshi = "0.1"
use yoshi::*;

fn load_config(path: &str) -> Result<String> {
    std::fs::read_to_string(path).map_err(|e| yoshi!(
        YoshiKind::Io,
        "Failed to read config file",
        path: path,
        source: e,
        suggestion: "Check file permissions and path"
    ))
}

fn main() -> Result<()> {
    match load_config("/etc/app/config.toml") {
        Ok(config) => println!("Config: {}", config),
        Err(err) => {
            // Rich, formatted error output
            eprintln!("Error: {}", err);
            // With full context chain
            eprintln!("Context: {:#}", err);
            return Err(err);
        }
    }

    Ok(())
}

Key Features

  • Powerful Macros - Create rich errors with one line using yoshi!, bail!, and ensure!
  • Structured Categories - Categorize errors with YoshiKind for consistent handling
  • Rich Context - Capture and chain context as errors bubble up
  • Metadata & Suggestions - Attach debugging data and provide fix suggestions
  • Derive Support - Generate error types and conversions with #[derive(YoshiError)]
  • No-std Compatible - Works in embedded environments

Concise Error Creation

// Use the expressive yoshi! macro
let error = yoshi!(
    YoshiKind::Database,
    "Failed to connect to database",
    host: "db.example.com",
    port: 5432,
    retry_count: 3,
    suggestion: "Check database credentials and firewall settings"
);

// Or derive your own error types
use yoshi_derive::YoshiError;

#[derive(Debug, YoshiError)]
pub enum ApiError {
    #[yoshi(kind = "NotFound")]
    #[yoshi(display = "User {user_id} not found")]
    UserNotFound { user_id: u64 },

    #[yoshi(kind = "Timeout")]
    RequestTimeout { seconds: u64 },
}

Documentation & Examples

License

Licensed under either of Apache License, Version 2.0 or MIT License at your option.


Made by ArcMoon Studios

About

Yoshi is a comprehensive error-handling framework designed for critical Rust applications that require detailed error diagnostics, structured error categorization, and high-performance error propagation.

Resources

License

Unknown and 2 other licenses found

Licenses found

Unknown
LICENSE
Unknown
LICENSE-APACHE
MIT
LICENSE-MIT

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •