You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- Add 'bytes' to FetchResponseType union
- Update dependency versions to latest
- Update test count from 28 to 83
- Add Error Handling Design section explaining sync vs async errors
**External dependencies are marked as external in vite.config.ts** - they are not bundled.
206
206
@@ -252,7 +252,7 @@ src/
252
252
- Tests are in `tests/fetch.test.ts`
253
253
- Uses Vitest as test framework
254
254
- Uses MSW (Mock Service Worker) for HTTP mocking
255
-
-28 test cases with 100% coverage
255
+
-83 test cases with 100% coverage
256
256
- Coverage includes:
257
257
- All response types (text, arraybuffer, blob, JSON)
258
258
- HTTP methods (GET, POST, PUT, PATCH, DELETE)
@@ -346,6 +346,20 @@ The `prepublishOnly` script automatically runs `pnpm run build`, which includes:
346
346
- CHANGELOG.md
347
347
- dist/
348
348
349
+
## Error Handling Design
350
+
351
+
`fetchT` distinguishes between two types of errors:
352
+
353
+
### Programming Errors (Synchronous)
354
+
Invalid parameters throw immediately for fail-fast behavior:
355
+
-`TypeError` for type validation (wrong type, not a function, invalid enum value)
356
+
-`Error` for value range validation (negative numbers, zero/negative timeout)
357
+
358
+
This differs from native `fetch`, which returns rejected Promises for parameter errors. Synchronous throws provide clearer stack traces and catch bugs during development.
359
+
360
+
### Runtime Errors (Result Type)
361
+
Network failures and HTTP errors are wrapped in `Result` type via `happy-rusty`. Use `.isOk()`, `.isErr()`, `.unwrap()`, `.unwrapErr()` for conditional handling.
362
+
349
363
## Known Issues & Gotchas
350
364
351
365
1.**Progress tracking requires Content-Length header**: If the server doesn't send this header, progress tracking will fail (onProgress receives an Err). The `Headers.get()` method is case-insensitive per the HTTP spec.
0 commit comments