#error-handling #utilities #swtools

sw-errors

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

2 releases

Uses new Rust 2024

new 0.0.2 Apr 20, 2025
0.0.1 Apr 20, 2025

#54 in #error-handling

Apache-2.0

12KB
173 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`:

```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

~4–10MB
~108K SLoC