/** * Was this thrown error a BILLING LIMIT refusal (HTTP 402) rather than a transport failure? * * IT EXISTS TO STOP A DOUBLE REPORT, not to produce one. `HttpService` already intercepts every 402, * reads the server's `billing` envelope and raises the app-wide billing-limit modal - and then still * throws, so a caller that reports its own failures paints a SECOND message about the same event. On the * video path that second message is the generic *"Billing limit reached"*, sitting beside a modal that * names the cap, the numbers and the add-on. The modal is the better reporter; the caller's job is to * fall silent, not to compete. * * This is the same rule `CallOverlay` already enforces for `call.error` - exactly one reporter per * event - applied one layer up, where the event has a better reporter than the overlay. * * Deliberately tolerant about the error's shape, mirroring `readClaimConflict`: the HTTP layer wraps * failures differently by path, and a 402 that silently read as an ordinary failure would put the wrong * sentence in front of a clinician. Reading only the status is enough here - the BODY has already been * consumed by `HttpService` to raise the modal, so re-deriving anything from it would be a second * opinion about money. */ export const isBillingLimitRefusal = (error: unknown): boolean => { const candidate = error as | { status?: number; statusCode?: number; response?: { status?: number } } | undefined; const status = candidate?.status ?? candidate?.statusCode ?? candidate?.response?.status; return status === 402; };