← スキル一覧に戻る

implement-error-handling
by Row0902
⭐ 0🍴 0📅 2026年1月21日
SKILL.md
name: Implement Error Handling description: Standards for robust, crash-proof exception handling and logging.
🛡️ Error Handling Skill
Context
An application "functioning to perfection" means it NEVER crashes unconditionally. It manages errors gracefully.
1. Hierarchy of Exceptions
Define custom exceptions in src/core/exceptions.py.
class AppError(Exception):
"""Base class for all application errors."""
pass
class ServiceError(AppError):
"""Errors in the service layer."""
pass
class UIError(AppError):
"""Errors in the UI layer."""
pass
2. The Safe UI Decorator
NEVER let an exception crash the GUI thread. Use a decorator for event handlers.
import functools
import wxcustom # Hypothetical util
from src.core.logging import get_logger
logger = get_logger(__name__)
def safe_event(func):
"""Swallows exceptions and shows an Error Dialog."""
@functools.wraps(func)
def wrapper(self, *args, **kwargs):
try:
return func(self, *args, **kwargs)
except Exception as e:
logger.exception("Uncaught UI Error")
wx.MessageBox(f"An unexpected error occurred: {e}", "Error", wx.ICON_ERROR)
return wrapper
3. Boundary Pattern
Service layers should catch low-level exceptions (e.g., requests.exceptions.ConnectionError) and re-raise them as domain exceptions (NetworkError), preserving the stack trace (raise ... from e).
def fetch_data():
try:
http_client.get(...)
except RequestException as e:
logger.error("Failed to fetch data")
raise ServiceError("Could not retrieve data") from e
4. Checklist
- Are UI event handlers decorated/protected?
- Are we using
logger.exception()in catch blocks? - Are we re-raising with context (
from e)?
スコア
総合スコア
35/100
リポジトリの品質指標に基づく評価
✓SKILL.md
SKILL.mdファイルが含まれている
+20
○LICENSE
ライセンスが設定されている
0/10
○説明文
100文字以上の説明がある
0/10
○人気
GitHub Stars 100以上
0/15
○最近の活動
3ヶ月以内に更新がある
0/10
○フォーク
10回以上フォークされている
0/5
✓Issue管理
オープンIssueが50未満
+5
○言語
プログラミング言語が設定されている
0/5
○タグ
1つ以上のタグが設定されている
0/5
レビュー
💬
レビュー機能は近日公開予定です