AgentStack
Browse Sign in
Browse Why AgentStack Sell Docs
Sign in
SKILL unreviewed MIT Self-run

Python Error Handling

skill-owenlamont-agent-skills-python-error-handling · by owenlamont

Handle errors in Python to this project's standards — custom domain exceptions, narrow catches, and failing fast. Use when raising or catching exceptions, writing try/except, designing an exceptions module, or deciding whether to swallow or propagate an error.

No reviews yet
0 installs
24 views
0.0% view→install

Install

$ agentstack add skill-owenlamont-agent-skills-python-error-handling

Open-source listing, not yet scanned by AgentStack. Follow the source repository for install instructions.

Security review

⚠ Flagged

1 finding(s); flagged for manual review. · v0.1.0 How review works →

  • Prompt-injection patterns
  • Secret / credential exfiltration
  • Dangerous shell & filesystem operations
  • Untrusted network calls
  • Known-malicious package signatures
  • high Dangerous shell/eval execution.

What it can access

  • Network access No
  • Filesystem access No
  • Shell / process execution Used
  • Environment & secrets No
  • Dynamic code execution No

From automated source analysis of v0.1.0. “Used” means the capability is present in the source — more access means more to trust, not that it’s unsafe.

View the full security report →

Reliability & compatibility

Not yet reviewed
0 installs to date
no reviews yet
2mo ago

Declared compatibility

Claude CodeClaude Desktop

Compatibility is declared by the source manifest. End-to-end runtime verification is coming, see below.

Preview Execution monitoring

We're building live execution health for every listing: tool-call success rate, median latency, uptime, and last-checked timestamps, measured, not self-reported. It isn't live yet, so we don't show numbers we can't stand behind.

How agent discovery & health will work →
Are you the author of Python Error Handling? Claim this listing to set pricing, connect Stripe payouts, and keep 70% of every sale.
Sign up to claim

About

Python Error Handling

Standards for raising, catching, and modelling exceptions.

Custom exceptions

  • Define domain exceptions in a dedicated exceptions module and raise those rather than

bare ValueError/RuntimeError/Exception, so call sites can catch precisely.

  • Subclass Exception, not a built-in like ValueError — inheriting from ValueError

means existing ValueError handlers silently swallow your exception, which is rarely what you want.

  • Keep the hierarchy flat — a handful of specific exceptions, optionally sharing one

package-level base class, not deep chains you must trace to know what a catch catches.

  • Name each exception for the failure it represents (RequestTimeoutError) and build

its message from the offending values, so the logged event is self-contained.

Catching exceptions

  • Catch the narrowest exception type you actually handle. A broad except Exception is

the Any of error handling — it swallows the unexpected and programmer errors (a KeyError, a PermissionError) that should propagate instead.

  • A broad except Exception is only correct at a top-level entry point — a

long-running loop or a CLI's main — as a last resort that reports and re-raises (or exits non-zero), so nothing is lost silently.

  • Keep try blocks down to the line or two that can actually raise, so it's obvious which

call is guarded.

  • Don't catch an exception only to log it and carry on — either handle it (recover) or let

it propagate. And don't log at an intermediate catch when it still bubbles to a handler that logs: log it once, where it's acted on.

Fail fast

  • Raise on impossible or coding-error states instead of logging-and-continuing or

returning None. A reached "can't happen" branch is a bug; make it fail loudly.

  • Let library failure checks fire: subprocess.run(..., check=True),

response.raise_for_status(), and the like — don't discard return codes or statuses.

  • When a 1:1 lookup could return zero or many rows, assert exactly one with

more_itertools.one() rather than silently taking the first.

  • Be consistent across sibling functions: a set of lookups should all raise on "not

found" or all return None, never a mix. Prefer raising, so callers can't forget to check.

  • Better still, model data so impossible states can't be constructed — see "make invalid

states unrepresentable" in python-code-style.

Log severity

  • Calibrate severity to recoverability: reserve critical for unrecoverable failures that

end the process, error/exception for failures needing attention, warning for a recovered or degraded path, info for normal events. Don't log at error for something you handled, nor bury a real failure at warning.

Source & license

This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.

Install and usage instructions live in the source repository linked above.

Reviews

No reviews yet, be the first.

Versions

  • v0.1.0 Imported from the upstream source.