#error-handling #utilities #swtools

sw-errors

A library for error parsing and pretty-printing, used across the swtools toolset

7 releases

Uses new Rust 2024

new 0.0.8 May 4, 2025
0.0.6 May 4, 2025
0.0.2 Apr 20, 2025

#1821 in Rust patterns

Download history 279/week @ 2025-04-16 31/week @ 2025-04-23 529/week @ 2025-04-30

839 downloads per month

Apache-2.0

15KB
239 lines

📦 sw-errors

A Rust library for parsing and displaying error messages in a clearer and more user-friendly way.

✨ Features

  • Structured error parsing
  • Human-friendly error display
  • Support for multiple output formats (JSON, plain text, etc.)
  • Easy integration with logging or CLI tools

🚀 Installation

Add this to your Cargo.toml:

[dependencies]
sw-errors = "0.1"

🛠️ Usage example

use sw_errors::ErrorParser;

fn main() {
    let raw_error = "thread 'main' panicked at 'index out of bounds', src/main.rs:10:5";
    
    let parsed = ErrorParser::new(raw_error).parse();

    println!("{}", parsed.pretty());
}

🧠 How it works

This library analyzes raw error messages and extracts useful information such as:

  • Error type
  • Code location
  • Root cause (if available)

💡 Motivation

Rust error messages can often be verbose or hard to understand, especially for beginners. This library aims to make them more readable and approachable.

📋 Roadmap

  • Parser for common panics
  • Support for anyhow::Error
  • Support for thiserror
  • CLI tool to pretty-print errors in the terminal

🤝 Contributing

Contributions are very welcome! Check out the CONTRIBUTING.md file to get started.

📄 License

Apache 2.0

Dependencies

~5–11MB
~126K SLoC