fix(web): open WebError.code to string, aligning with other seams

The closed WebErrorCode union leaked fetch-transport details (redirect,
too-large, content-type) into the seam's shared vocabulary and made web
the only seam with a closed error-code union. Drop it and let WebError
carry an open code: string like LlmError/SubagentError; document the
codes grouped by owner (seam-neutral vs dsh-web-fetch-local transport).

Addresses tianyicui's leaky-abstraction review comment on WebErrorCode.
This commit is contained in:
Dudu-0223
2026-07-03 15:52:05 +08:00
parent cf71c0b215
commit 7441307251
6 changed files with 25 additions and 59 deletions

View File

@@ -95,24 +95,7 @@ Selection never depends on registration, config, or HMR order: a capability has
## Errors
`WebError extends HarnessError` ([core.md](core.md) error taxonomy) with a stable `WebErrorCode`. `WEB_DUPLICATE_PROVIDER` is a registration-time programming error (the analogue of `LlmService`'s `DUPLICATE_ADAPTER`); the `WEB_PROVIDER_*` selection codes and the fetch transport codes are execution outcomes. `WEB_PROVIDER_ERROR` is the catch-all for a provider's own failure surfaced through the seam, including network/transport failure (DNS, connection refused, TLS).
```ts type-equiv
type WebErrorCode =
| 'WEB_PROVIDER_UNAVAILABLE'
| 'WEB_PROVIDER_CONFIGURED_MISSING'
| 'WEB_PROVIDER_CONFIGURED_UNAVAILABLE'
| 'WEB_PROVIDER_AMBIGUOUS'
| 'WEB_DUPLICATE_PROVIDER'
| 'WEB_INVALID_URL'
| 'WEB_BLOCKED_URL'
| 'WEB_REDIRECT_BLOCKED'
| 'WEB_FETCH_TOO_LARGE'
| 'WEB_FETCH_TIMEOUT'
| 'WEB_ABORTED'
| 'WEB_UNSUPPORTED_CONTENT_TYPE'
| 'WEB_PROVIDER_ERROR'
```
`WebError extends HarnessError` ([core.md](core.md) error taxonomy) with a `code: string` (open, like every other seam's error — `LlmError`, `SubagentError`), not a closed union: a provider may raise its own codes without editing `dsh-web`, and consumers must tolerate an unknown code. The codes split by owner. Seam-neutral codes are raised by `WebService` selection and the shared contract: `WEB_PROVIDER_UNAVAILABLE`, `WEB_PROVIDER_CONFIGURED_MISSING`, `WEB_PROVIDER_CONFIGURED_UNAVAILABLE`, `WEB_PROVIDER_AMBIGUOUS`, `WEB_DUPLICATE_PROVIDER` (a registration-time programming error, the analogue of `LlmService`'s `DUPLICATE_ADAPTER`), `WEB_ABORTED`, and `WEB_PROVIDER_ERROR` (the catch-all for a provider's own failure surfaced through the seam, including network/transport failure DNS, connection refused, TLS). Fetch-transport codes are owned by the `dsh-web-fetch-local` implementation and a different fetch backend need not raise them: `WEB_INVALID_URL`, `WEB_BLOCKED_URL`, `WEB_REDIRECT_BLOCKED`, `WEB_FETCH_TOO_LARGE`, `WEB_FETCH_TIMEOUT`, `WEB_UNSUPPORTED_CONTENT_TYPE`.
## The service