rust-patterns
Installation
SKILL.md
Rust Patterns
Error Handling
// Librerías: thiserror
#[derive(Debug, thiserror::Error)]
enum AppError {
#[error("not found: {0}")]
NotFound(String),
#[error("database error")]
Database(#[from] sqlx::Error),
}
// Aplicaciones: anyhow
fn main() -> anyhow::Result<()> {
let config = load_config().context("failed to load config")?;
Ok(())
}