fp-errors

Featured

Stop throwing everywhere - handle errors as values using Either and TaskEither for cleaner, more predictable code

AI & Automation 39,350 stars 6386 forks Updated today MIT

Install

View on GitHub

Quality Score: 99/100

Stars 20%
100
Recency 20%
100
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
50
License 10%
100
Description 5%
100

Skill Content

# 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. 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. ## When to Use - You need to replace exception-heavy code with `Either` or `TaskEither`. - The task involves validation, domain errors, or clearer error contracts in TypeScript. - You want pragmatic fp-ts error-handling guidance for real application code. --- ## 1. Stop Throwing Everywhere ### The Problem with Exceptions Exceptions are invisible in your types. They break the contract between functions. ```typescript // What this function signature promises: function getUser(id: string): User // What it actually does: function getUser(id: string): User { if (!id) throw new Error('ID required') const user = db.find(id) if (!user) throw new Error('User not found') return user } // The caller has no idea this can fail const user = getUser(id) // Might explode! ``` You end up with code like this: ```typescript // MESSY: try/catch everywhere function processOrder(orderId: string) { let order try { order = getOrder(orderId) } catch (e) { console.error('Failed to get order') return null } let user try { user = getUser(order.userId) } catch (e) { console.error('Failed to get user') return null ...

Details

Author
sickn33
Repository
sickn33/antigravity-awesome-skills
Created
4 months ago
Last Updated
today
Language
Python
License
MIT

Similar Skills

Semantically similar based on skill content — not just same category