robust-error-handling-in-scripts
Installation
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)