https://github.com/dominikj111/error-kit
🦀 Rust error handling library built on thiserror, providing standardized error messages, ergonomic constructor functions, and type-safe error patterns for developer-focused applications.
https://github.com/dominikj111/error-kit
error-handling error-management error-patterns rust thiserror
Last synced: 3 months ago
JSON representation
🦀 Rust error handling library built on thiserror, providing standardized error messages, ergonomic constructor functions, and type-safe error patterns for developer-focused applications.
- Host: GitHub
- URL: https://github.com/dominikj111/error-kit
- Owner: dominikj111
- License: bsd-3-clause
- Created: 2025-09-08T07:42:16.000Z (8 months ago)
- Default Branch: main
- Last Pushed: 2025-09-08T08:29:09.000Z (8 months ago)
- Last Synced: 2025-09-09T08:42:25.442Z (8 months ago)
- Topics: error-handling, error-management, error-patterns, rust, thiserror
- Language: Rust
- Homepage:
- Size: 9.26 MB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# error-kit 🦀 ⚡
[](https://crates.io/crates/error-kit)
[](https://docs.rs/error-kit)
[](https://opensource.org/licenses/BSD-3-Clause)
[](https://deps.rs/repo/github/dominikj111/resourcely)
[](https://www.rust-lang.org/)
A comprehensive, developer-focused error handling infrastructure built on top of `thiserror`, providing standardized error messages, common error patterns, and ergonomic helper functions.
## Design Principles 🏗️
This crate provides a "batteries-included" approach to error handling with these core principles:
### Developer-Focused Messages 👩💻
Error messages provide technical context for developers, not end-user UI text.
### Type-Safe Enums Over Error Codes 🔢
Uses `thiserror::Error` derive macro for compile-time checking, pattern matching, and IDE support.
### Helper Functions Over Macros 🚀
Explicit, debuggable functions instead of complex macros:
```rust
// Clear and debuggable ✨
CommonError::io_error("Failed to read config file")
// Instead of macro magic 🪄❌
error!("Failed to read config file")
```
### Centralized Message Constants 📚
Error messages defined as constants in a dedicated `messages` module for consistency and maintainability.
## Usage Examples 💡
### Adding error-kit to Your Project 📦
```rust
// Add to Cargo.toml
[dependencies]
error-kit = "0.1.0"
```
### Using error-kit 🚀
```rust
use error_kit::CommonError;
// Using helper functions 🔧
let io_err = CommonError::io_error("Failed to read config file");
let filename_err = CommonError::filename_error();
// Using predefined message constants 📝
let timeout_err = CommonError::Timeout; // Uses messages::TIMEOUT_EXCEEDED
// Simple error handling 🎯
let result: Result = some_operation();
match result {
Err(e) => eprintln!("Error: {}", e),
Ok(data) => process_data(data),
}
// Or pattern matching when you need specific handling
match result {
Err(CommonError::Io(_)) => handle_io_error(),
Err(CommonError::Timeout) => retry_operation(),
Err(CommonError::FilenameError) => handle_filename_issue(),
Err(e) => eprintln!("Error: {}", e),
Ok(data) => process_data(data),
}
```
## Module Structure 🏗️
The `error-kit` crate is organized into focused modules:
- **`messages`**: Centralized error message constants
- **`constructors`**: Ergonomic constructor functions
- **`types`**: Main error enum with `thiserror` integration
```rust
use error_kit::{
CommonError, // Main error type 🎯
messages, // Message constants 📚
constructors, // Helper constructor functions 🚀
};
```
## Use Cases 🎯
- **Library Development**: Structured error types with consistent messaging
- **Application Development**: Standardized error handling with reduced boilerplate
- **Error Infrastructure**: Foundation for domain-specific error crates and company standards
## Future Vision 🔮
This crate aims to become the go-to foundation for error handling, providing:
- Domain-specific error modules (network, filesystem, parsing, etc.)
- Error reporting utilities and formatters
- Integration helpers for popular crates
- Best practice examples and patterns
- Community-driven error message standards
---
## Contributing 🤝
We welcome contributions! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
## License 📄
This project is licensed under the BSD 3-Clause License - see the [LICENSE](LICENSE) file for details.