Skip to content

Commit b6d727e

Browse files
committed
update knowledge.md to prefer returning errors
1 parent bf6c5d1 commit b6d727e

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

knowledge.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,16 @@ base-lite "fix this bug" # Works right away!
8888
- Always clean build state when encountering persistent type errors or infinite loops
8989
- The monorepo structure with project references can sometimes create dependency cycles
9090

91+
## Error Handling Philosophy
92+
93+
**Prefer `ErrorOr<T>` return types over throwing errors.**
94+
95+
- Return type `ErrorOr<T>` for operations that fail
96+
- Return `success(value)` or `failure(error)` from `common/src/util/error.ts`
97+
- e.g. `return failure(new Error('File not found'))`
98+
- Allows callers to handle errors explicitly without try-catch
99+
- Makes error cases visible in function signatures
100+
91101
## Error Handling and Debugging
92102

93103
- Error messages are logged to console and debug log files

0 commit comments

Comments
 (0)