- 优先考虑错误处理和边缘情况:
- 在函数开始时处理错误和边缘情况。
- 对错误条件使用早期返回以避免深度嵌套的 if 语句。
- 将正常路径放在函数最后以提高可读性。
- 避免不必要的 else 语句;使用 if-return 模式代替。
- 使用守卫子句早期处理前置条件和无效状态。
- 实现适当的错误日志记录和用户友好的错误消息。
- 考虑使用自定义错误类型或错误工厂以实现一致的错误处理。
Nextjs React TS Error Handling And Validation
在所有代码中优先考虑错误处理和边缘情况。定义如何管理错误、处理前置条件和实现日志记录。
Nextjs React TS Error Handling And Validation by liaosw97 · 8a28b87
npx skillmds@latest add liaosw97/nextjs-react-ts-error-handling-and-validation File contents
---name: nextjs-react-ts-error-handling-and-validationdescription: 在所有代码中优先考虑错误处理和边缘情况。定义如何管理错误、处理前置条件和实现日志记录。---- 优先考虑错误处理和边缘情况: - 在函数开始时处理错误和边缘情况。 - 对错误条件使用早期返回以避免深度嵌套的 if 语句。 - 将正常路径放在函数最后以提高可读性。 - 避免不必要的 else 语句;使用 if-return 模式代替。 - 使用守卫子句早期处理前置条件和无效状态。 - 实现适当的错误日志记录和用户友好的错误消息。 - 考虑使用自定义错误类型或错误工厂以实现一致的错误处理。
liaosw97/awesome-rules-skills/tree/main/plugins/nextjs/skills/nextjs-react-ts-error-handling-and-validation commit 8a28b87641
Frequently asked questions
Run npx skillmds@latest add liaosw97/nextjs-react-ts-error-handling-and-validation in your terminal (requires Node.js), paste this page's agent-chat prompt into Claude, Cursor, or any MCP-connected agent, or download the SKILL.md file and copy it into your agent's skills directory.
在所有代码中优先考虑错误处理和边缘情况。定义如何管理错误、处理前置条件和实现日志记录。 It is listed under Web & Frontend on SkillMD.
This skill has not completed SkillMD's automated safety review yet. Capability flags: docs only. SkillMD never runs a skill's scripts for you; review the SKILL.md before installing.
This skill is tagged as working with Claude Code, Claude.ai, OpenAI Codex. SKILL.md is an open format, so most agents that read a skills directory can load it too.
Yes. Installing skills from SkillMD is free, and the skill stays under its author's original license.
liaosw97 (@liaosw97) published this skill. Their other Agent Skills are listed on their SkillMD profile.