What problem does it solve?
This Skill provides expert guidance on advanced Rust error handling strategies, helping developers build robust and maintainable applications by effectively managing expected failures, library vs. application errors, and error context.
Core Features & Use Cases
- Error Type Selection: Differentiates between
Result, Option, and panic! for appropriate use cases.
- Library vs. Application Errors: Guides the use of
thiserror for libraries and anyhow for applications.
- Error Context and Propagation: Demonstrates how to add context using
.context() and propagate errors with ? and #[from].
- Use Case: You are building a Rust web service and need to handle various potential failures like database connection errors, invalid user input, and external API call failures. This skill will help you structure your error handling to provide clear, actionable error messages to both the end-user and for debugging.
Quick Start
Use the rust-error-advanced skill to understand when to use thiserror versus anyhow for error handling in Rust.