AgentStack
SKILL unreviewed MIT Self-run

Catch Expected Errors

skill-jimmc414-claude-code-plugin-marketplace-catch-expected-errors · by jimmc414

For iteration with errors: catch exceptions during exploration, skip invalid cases, continue to next attempt.

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

Install

$ agentstack add skill-jimmc414-claude-code-plugin-marketplace-catch-expected-errors

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 No
  • Environment & secrets No
  • Dynamic code execution Used

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.

Are you the author of Catch Expected Errors? Claim this listing to set pricing, connect Stripe payouts, and keep 70% of every sale.
Sign up to claim

About

catch-expected-errors

When to Use

  • Trying many possibilities where some fail
  • Division by zero might occur naturally
  • Type conversion might fail
  • Exploring invalid states in search

When NOT to Use

  • Errors indicate bugs (let them propagate)
  • All inputs should be valid
  • Exception overhead matters

The Pattern

Wrap potentially failing code in try/except, continue on expected errors.

for candidate in candidates:
    try:
        result = process(candidate)
        if is_valid(result):
            return result
    except (ValueError, ArithmeticError):
        continue  # Skip this candidate

return None  # None worked

Example (from pytudes)

# Cryptarithmetic solver (Cryptarithmetic.ipynb)
def faster_solve(formula):
    """Fill in digits to solve formula."""
    python_lambda, letters = translate_formula(formula)
    formula_fn = eval(python_lambda)

    for digits in permutations((1,2,3,4,5,6,7,8,9,0), len(letters)):
        try:
            if formula_fn(*digits) is True:
                yield format_solution(digits, letters, formula)
        except ArithmeticError:
            pass  # Division by zero - skip this combination

# Simple validator (Cryptarithmetic.ipynb)
def valid(pformula):
    """Valid iff no leading zero and evaluates to True."""
    try:
        return (not leading_zero(pformula)) and (eval(pformula) is True)
    except ArithmeticError:
        return False

# Type conversion cascade (lispy.py)
def atom(token):
    """Convert token to appropriate type."""
    if token == '#t': return True
    if token == '#f': return False
    if token[0] == '"': return token[1:-1]

    try:
        return int(token)
    except ValueError:
        try:
            return float(token)
        except ValueError:
            try:
                return complex(token.replace('i', 'j', 1))
            except ValueError:
                return Sym(token)

# Version compatibility (beal.py)
try:
    from math import gcd
except ImportError:
    from fractions import gcd

Key Principles

  1. Specific exceptions: Catch exactly what's expected
  2. Don't catch Exception: Too broad, hides bugs
  3. pass or continue: Skip failed case, try next
  4. Nested try for cascade: Each level handles one failure
  5. Expected, not exceptional: Error is part of normal operation

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.