Skip to content

Commit 67e2952

Browse files
committed
docs: add @praha/byethrow error handling guidelines to CLAUDE.md
Document the preference for using @praha/byethrow Result type over traditional try-catch patterns with best practices and usage guidelines
1 parent ceb60b6 commit 67e2952

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

‎CLAUDE.md‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,16 @@ This is a CLI tool that analyzes Claude Code usage data from local JSONL files s
109109
- File paths always use Node.js path utilities for cross-platform compatibility
110110
- **Import conventions**: Use `.ts` extensions for local file imports (e.g., `import { foo } from './utils.ts'`)
111111

112+
**Error Handling:**
113+
114+
- **Prefer @praha/byethrow Result type** over traditional try-catch for functional error handling
115+
- Use `Result.try()` for wrapping operations that may throw (JSON parsing, etc.)
116+
- Use `Result.isFailure()` for checking errors (more readable than `!Result.isSuccess()`)
117+
- Use early return pattern (`if (Result.isFailure(result)) continue;`) instead of ternary operators
118+
- For async operations: create wrapper function with `Result.try()` then call it
119+
- Keep traditional try-catch only for: file I/O with complex error handling, legacy code that's hard to refactor
120+
- Always use `Result.isFailure()` and `Result.isSuccess()` type guards for better code clarity
121+
112122
**Naming Conventions:**
113123

114124
- Variables: start with lowercase (camelCase) - e.g., `usageDataSchema`, `modelBreakdownSchema`

0 commit comments

Comments
 (0)