跳到正文
Skillpedia
通用编程75k · #2833

error-handling

它能做什么

这项技能检查代码如何处理错误,尤其是异步任务和 React 组件中的错误。适用于希望应用能优雅地处理失败、并且更易于调试的开发者。

适用场景

  • ✓当你的应用在出错后崩溃或变成空白页面的时候。
  • ✓当异步请求失败而没有任何消息或日志的时候。
  • ✓当你在构建 React 应用,并希望错误被限制在屏幕的某一部分的时候。

技能链接

https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/error-handling/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/error-handling/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“请检查我的代码,确保错误得到了妥善处理。”

每周 5 个新技能,1 分钟读完。

工作原理

智能体会查找没有 try-catch 代码块的异步操作,以及被悄悄忽略的错误。它会建议捕获这些错误、记录有用的上下文,并在 React 中添加错误边界。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

Implement proper error handling

Unhandled errors crash applications, create poor user experiences, and make debugging impossible without proper context.

Quick Reference

  • Wrap async operations in try-catch blocks
  • Use Error Boundaries in React for UI-level error handling
  • Log errors with context for debugging
  • Always re-throw or handle—never silently swallow errors

Check

Review error handling in this code, ensuring async operations use try-catch and errors are properly logged.

Fix

Add try-catch blocks to async operations and implement error boundaries for React components.

Explain

Explain JavaScript error handling best practices including try-catch, Promise rejection, and error boundaries.

Code Review

Review scripts, client components, and browser execution paths related to Implement proper error handling. Flag exact imports, event handlers, runtime side effects, or blocking operations that violate the rule, and state how the change should be verified in the browser.


For full implementation details, code examples, and framework-specific guidance, see references/rule.md.

Rule page: https://frontendchecklist.io/rules/javascript/error-handling

常见问题

什么是错误边界?

在 React 中,它是一个组件,能捕获其子组件中的错误,并显示备用内容,而不是让整个屏幕崩溃。

忽略错误可以接受吗?

这项技能说明绝不能悄悄吞掉错误。每个错误都应被处理或继续向上传递。

它会检查 Promise 的拒绝吗?

会。这项技能把未处理的 Promise 拒绝也纳入良好错误处理的范围。

详情

作者的原始描述

Use when reviewing scripts, client components, bundles, or runtime behavior related to Implement proper error handling. Inspect both source code and the browser execution path so fixes target the real bottleneck or bug.

repo: thedaviddias/Front-End-Checklist

热度

GitHub 星标
75k
排名
#2833
许可证
MIT
更新时间
2026/10/31

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能