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
最近来源活动
2026年3月10日 18:04
检测到的 SKILL.md 语言
英语
星标
3,464
Forks
452

安装方式

默认使用会先检查来源的 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 查看