wshobson avatar

Python Error Handling

This covers the error handling patterns you actually need in production Python code. It shows you how to validate inputs early with clear error messages, use Pydantic for complex validation, chain exceptions to preserve debug context, and handle partial failures in batch operations without aborting everything. The custom exception hierarchy examples are solid, and the batch processing pattern that tracks successes and failures separately will save you headaches when processing large datasets. Good practical coverage of turning messy failure scenarios into manageable, debuggable code.

skills.sh installs
14.7K
GitHub stars
42.4K
last updated
Aug 21, 2026

Install

$ npx -y skills add wshobson/agents --skill python-error-handling --agent claude-code

Installs into .claude/skills of the current project.

Files

Python Error Handling

Build robust Python applications with proper input validation, meaningful exceptions, and graceful failure handling. Good error handling makes debugging easier and systems more reliable.

When to Use This Skill

  • Validating user input and API parameters
  • Designing exception hierarchies for applications
  • Handling partial failures in batch operations
  • Converting external data to domain types
  • Building user-friendly error messages
  • Implementing fail-fast validation patterns

Core Concepts

1. Fail Fast

Validate inputs early, before expensive operations. Report all validation errors at once when possible.

2. Meaningful Exceptions

Use appropriate exception types with context. Messages should explain what failed, why, and how to fix it.

3. Partial Failures

In batch operations, don't let one failure abort everything. Track successes and failures separately.

4. Preserve Context

Chain exceptions to maintain the full error trail for debugging.

Quick Start

Sponsors

Details

Repository
github.com/wshobson/agents
Categories
Debugging, Automation & Workflows, Python

More from wshobson/agents

All 174

Recommended

More Debugging
1openai avatargh-fix-ciopenai/skillsUse when a user asks to debug or fix failing GitHub PR checks that run in GitHub Actions; use `gh` to inspect checks and logs, summarize failure context, draft 11.8Kskills.sh installs
2getsentry avatarsentry-fix-issuesgetsentry/sentry-for-aiFind and fix issues from Sentry using MCP. Use when asked to fix Sentry errors, debug production issues, investigate exceptions, or resolve bugs reported in Sen10.4Kskills.sh installs
3wshobson avatarparallel-debuggingwshobson/agentsDebug complex issues using competing hypotheses with parallel investigation, evidence collection, and root cause arbitration. Use this skill when debugging bugs10.4Kskills.sh installs
4clickhouse avatarclickhouse-js-node-troubleshootingclickhouse/agent-skillsTroubleshoot and resolve common issues with the ClickHouse Node.js client (@clickhouse/client). Use this skill whenever a user reports errors, unexpected behavi7.8Kskills.sh installs
5aws avatartroubleshooting-s3-filesaws/agent-toolkit-for-awsDiagnoses and resolves Amazon S3 Files issues including mount failures, permission errors, synchronization problems, and performance issues. Use when the user h6.7Kskills.sh installs
6wordpress avatarwp-performancewordpress/agent-skillsUse when investigating or improving WordPress performance (backend-only agent): profiling and measurement (WP-CLI profile/doctor, Server-Timing, Query Monitor v6.7Kskills.sh installs