skills/aiming-lab/metaclaw/robust-error-handling-in-scripts

robust-error-handling-in-scripts

SKILL.md

Robust Error Handling in Scripts

Shell scripts:

set -euo pipefail  # Exit on error, undefined var, pipe failure
trap 'echo "Failed at line $LINENO"' ERR

Python scripts:

import logging, sys
logging.basicConfig(level=logging.INFO, format='%(asctime)s %(levelname)s %(message)s')
try:
    main()
except Exception as e:
    logging.exception("Unhandled error: %s", e)
    sys.exit(1)

Retry with backoff for transient network/API failures:

from tenacity import retry, stop_after_attempt, wait_exponential
@retry(stop=stop_after_attempt(3), wait=wait_exponential(min=2, max=10))
def call_api(): ...
Weekly Installs
2
GitHub Stars
1.3K
First Seen
3 days ago
Installed on
amp2
cline2
opencode2
cursor2
kimi-cli2
codex2