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
{{ message }}
Repository navigation
Commit b592061
Browse filesBrowse the repository at this point in the historyBrowse files
refactor(client, contract, json-schema)!: make ORPCError code and data readonly and fix the name brand (#2523)
Pre-stable cleanup of the `ORPCError` surface.
## What changed
- **Name brand:** the type brand on `ORPCError#name` was spelled
`__branch`; it is now `__brand`. It was introduced once in the v2 commit
with a JSDoc that calls it "type branding", so this is a typo fix that
shows up in hover types.
- **Readonly `code` and `data`:** both are now `readonly`, like
`defined`, so a defined error cannot be changed in place after it was
matched against the error map. This is intentionally not documented.
- **`COMMON_ERROR_STATUS_MAP`:** declared `as const`, so its values are
literal types and writes are a type error. It is not frozen at runtime.
## Breaking
- Assigning `error.code` or `error.data` no longer type-checks.
- `COMMON_ERROR_STATUS_MAP` values are literal types instead of
`number`, and assigning to its keys no longer type-checks.
## Notes for review
- The two internal writers of `data` (`reconcileORPCError` in
`@orpc/contract` and the smart coercion link plugin in
`@orpc/json-schema`) set it on a fresh clone through a `Writable` cast,
the same pattern already used for `defined`.
- `ORPCError` still has no `defined` constructor option, and
`cloneORPCError` is unchanged.
- No docs or migration notes changed.
0 commit comments