← スキル一覧に戻る

rust-error-handling
by Dicklesworthstone
rust-error-handlingは、other分野における実用的なスキルです。複雑な課題への対応力を強化し、業務効率と成果の質を改善します。
⭐ 93🍴 18📅 2026年1月23日
SKILL.md
id: rust-error-handling name: Rust Error Handling description: >- Rust-specific error handling patterns, building on the base error handling skill. Demonstrates the 'extends' composition feature. tags: [error-handling, rust, example] extends: error-handling-base
Rust Error Handling
Rust-specific error handling patterns that extend the base error handling skill.
Rules
- Use
thiserrorfor defining library error types - Use
anyhowfor application-level error handling - Implement
std::error::Errortrait for custom error types - Use the
?operator for ergonomic error propagation - Prefer
Result<T, E>over panicking for recoverable errors - Use
unwrap()only in tests or when failure is impossible
Examples
// Define library errors with thiserror
use thiserror::Error;
#[derive(Error, Debug)]
pub enum ConfigError {
#[error("failed to read config file: {0}")]
Io(#[from] std::io::Error),
#[error("invalid config format: {0}")]
Parse(#[from] toml::de::Error),
#[error("missing required field: {field}")]
MissingField { field: String },
}
// Application-level error handling with anyhow
use anyhow::{Context, Result};
fn load_config(path: &str) -> Result<Config> {
let content = std::fs::read_to_string(path)
.with_context(|| format!("failed to read config from {}", path))?;
let config: Config = toml::from_str(&content)
.context("failed to parse config TOML")?;
Ok(config)
}
Checklist
- Custom error types use
thiserrorderive - Error context is added with
anyhow::Context - No
unwrap()calls in production code paths -
Resultis used instead ofpanic!for recoverable errors
スコア
総合スコア
75/100
リポジトリの品質指標に基づく評価
✓SKILL.md
SKILL.mdファイルが含まれている
+20
✓LICENSE
ライセンスが設定されている
+10
✓説明文
100文字以上の説明がある
+10
○人気
GitHub Stars 100以上
0/15
○最近の活動
3ヶ月以内に更新がある
0/10
✓フォーク
10回以上フォークされている
+5
✓Issue管理
オープンIssueが50未満
+5
✓言語
プログラミング言語が設定されている
+5
○タグ
1つ以上のタグが設定されている
0/5
レビュー
💬
レビュー機能は近日公開予定です