Typed errors used throughout 2.0 to drive retry policy and consumer UI decisions.
Why two classes (not a discriminator field):
instanceof
if (error instanceof TerminalError) renderInline()
instanceof TransientError
4xx → TerminalError (no retry — the request is structurally wrong: unauthorized, not-found, schema mismatch, validation failure).
TerminalError
5xx + network failures → TransientError (engine retries with exponential backoff up to maxRetries).
TransientError
maxRetries
Custom transports can throw either class. The default REST helper (makeRestTransport) maps HTTP status codes to the appropriate class automatically.
makeRestTransport
Both classes preserve the original error via the standard cause option so stack traces survive the boundary.
cause
Optional
Original thrown value (Error, Response, anything).
Error
Response
HTTP status if the underlying transport was HTTP.
Typed errors used throughout 2.0 to drive retry policy and consumer UI decisions.
Why two classes (not a discriminator field):
instanceofchecks are zero-cost at runtime and survive bundler minification of property names.if (error instanceof TerminalError) renderInline()without importing a type-narrowing helper.instanceof TransientErrorcheck.4xx →
TerminalError(no retry — the request is structurally wrong: unauthorized, not-found, schema mismatch, validation failure).5xx + network failures →
TransientError(engine retries with exponential backoff up tomaxRetries).Custom transports can throw either class. The default REST helper (
makeRestTransport) maps HTTP status codes to the appropriate class automatically.Both classes preserve the original error via the standard
causeoption so stack traces survive the boundary.