跳到正文
Skillpedia
通用编程48k · #4649

fp-ts-errors

它能做什么

这个工具讲解如何有条理地处理程序错误,把错误当作计算机能够理解和追踪的信息,而不是直接丢弃。

适用场景

  • ✓当你希望代码能够安全、可预测地处理错误时。
  • ✓当你想避免使用容易让代码变得混乱的 `try/catch` 时。
  • ✓当你在构建需要明确识别各类可能错误的系统时。

技能链接

https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/fp-ts-errors/SKILL.md

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

使用方法

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

可直接粘贴的消息

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

可以这样问 AI

“我该如何运用这种技巧,确保我的代码能安全地处理错误?”

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

工作原理

程序出错时不会直接“崩溃”,而是把错误作为数据返回。这样,程序就能清楚地知道问题是什么,并以可控的方式处理它。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

Practical Error Handling with fp-ts

This skill teaches you how to handle errors without try/catch spaghetti. No academic jargon - just practical patterns for real problems.

Detailed Guide

Read the detailed guide before executing this skill. It retains the complete procedure and reference material. Treat its safety, prerequisites, and validation requirements as mandatory. For focused work, load the relevant sections; for end-to-end work, read the guide completely.

When to Use This Skill

  • When you want type-safe error handling in TypeScript
  • When replacing try/catch with Either and TaskEither patterns
  • When building APIs or services that need explicit error types
  • When accumulating multiple validation errors

The core idea: Errors are just data. Instead of throwing them into the void and hoping someone catches them, return them as values that TypeScript can track.


Limitations

  • Use this skill only when the task clearly matches the scope described above.
  • Do not treat the output as a substitute for environment-specific validation, testing, or expert review.
  • Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.
常见问题

什么是 `Either` 和 `TaskEither`?

它们是组织代码的方式,让代码既能返回成功的结果,也能返回错误,而且清晰、安全。

为什么要避免使用 `try/catch`?

`try/catch` 会让代码难以阅读和理解,尤其是在错误类型很多的时候。这种技巧提供了一种更有条理的替代方案。

“错误即数据”是什么意思?

意思是把错误当作程序可以使用和追踪的信息,而不是仅仅当作意料之外的中断。

详情

作者的原始描述

Handle errors as values using fp-ts Either and TaskEither for cleaner, more predictable TypeScript code. Use when implementing error handling patterns with fp-ts.

repo: sickn33/agentic-awesome-skills

热度

GitHub 星标
48k
排名
#4649
许可证
MIT
更新时间
2026/10/15

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能