Skip to main content

@dialstack/sdk-dev / js/src / isApiError

Function: isApiError()

TypeScript
function isApiError(err): err is ApiError;

Defined in: sdk/js/src/core/instance.ts:122

Structural check for an ApiError, for callers in other packages.

Prefer this over err instanceof ApiError across a package boundary. The error is constructed here but caught elsewhere — @dialstack/sdk-react handles 409 and 422 from the onboarding flow — and instanceof compares against one specific class object, so it silently returns false whenever the two sides resolve different module instances: a duplicated install, a bundler that fails to dedupe, or an error crossing a realm.

Which is why there is no instanceof Error gate either. That would reintroduce the same failure one level up: Error is a per-realm intrinsic, so an error thrown in an iframe, a worker or a vm context is not an instanceof Error in the parent even though every field below is intact. The check reads only fields the error carries, so it cannot skew — and message/stack are not among them because nothing narrows on them.

Parameters

err

unknown

Returns

err is ApiError