Skip to main content

robust-error-handling-in-scripts

Use this skill when writing shell scripts, Python automation, or any unattended batch job. Ensure failures are detected, logged, and handled — never silently ignored.

معلومات المصدر

المستودع
aiming-lab/MetaClaw
آخر نشاط في المصدر
١٠ مارس ٢٠٢٦ في ١٨:٠٤
لغة SKILL.md المكتشفة
الإنجليزية
النجوم
٣٬٤٦٤
التفرعات
٤٥٢

خيارات التثبيت

يُحدَّد Prompt الذي يراجع المصدر أولًا بشكل افتراضي. يمكنك التبديل إلى أمر مباشر أو تنزيل نسخة محلية.

مراجعة ملفات المصدر

اقرأ SKILL.md وأي ملفات مرافقة يعرضها SkillsMP قبل أن تقرر التثبيت.

عرض SKILL.md

SKILL.md
تعليمات المصدر · معاينة للقراءة فقط
name
robust-error-handling-in-scripts
description
Use this skill when writing shell scripts, Python automation, or any unattended batch job. Ensure failures are detected, logged, and handled — never silently ignored.
category
automation
# Robust Error Handling in Scripts **Shell scripts:** ```bash set -euo pipefail # Exit on error, undefined var, pipe failure trap 'echo "Failed at line $LINENO"' ERR ``` **Python scripts:** ```python 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: ```python 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(): ... ```
عرض على GitHub