360 Secure SkillHub
360 安全技能中心

Missing Error Handling

该 Skill 以清单形式说明外部调用、文件 I/O、子进程和解析等场景的常见失败模式,并给出添加超时、检查状态码、捕获具体异常和记录上下文的改进建议;不包含可执行代码或自动扫描。

mvogt99
mvogt99
热度 41.70
最近更新 2026-05-11 17:46:01
分类:开发依赖:纯提示词应用场景:代码审查 / 调试排错

安装技能

复制下面的话术发给你的 Agent,它会通过 secure-skills 检索并安装该技能。

执行命令安装此 skill: npx secure-skills-cli add missing-error-handling
Metadata
name
missing-error-handling
description
Code handles only the happy path — external calls, I/O, and parsing have no failure handling and crash on anything unexpected.
emoji
⚠️
metadata
{"clawdis":{"os":["macos","linux","windows"]}}

missing-error-handling

Every external interaction is a source of failure: network, disk, subprocess, parsing, third-party API. If the code assumes they always succeed, a production run will hit the first unexpected condition and crash unhelpfully.

Symptoms

  • HTTP calls without status-code checks and without timeout.
  • File I/O with no handling for missing files, permission denied, or partial reads.
  • Subprocess calls that ignore non-zero exit codes.
  • JSON.parse / yaml.load with no handling of malformed input.
  • Broad except: / catch (e) {} that swallows everything without logging.

What to do

  • For each external call, list the failure modes explicitly: timeout, non-2xx status, missing resource, malformed payload, permissions. Handle each with specific recovery or a loud failure.
  • Add a timeout to every network call. No exceptions.
  • When catching, catch the specific exception types you can actually recover from. Let unknown errors propagate with context.
  • When swallowing is unavoidable, log the full error with context — at minimum, the operation that failed and the arguments.
  • Distinguish "user-visible error" (explain, ask them to retry or adjust) from "internal error" (log with stack, fail fast). Don't leak internal errors to users.