{"record":{"id":"431554be5ca2c8f1","repo":"koala73/worldmonitor","slug":"sign-in-to-action","errorCode":null,"errorMessage":"Sign in to ${action}.","messagePattern":"Sign in to (.+?)\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/services/billing.ts","lineNumber":77,"sourceCode":"function normalizeCaughtError(action: string, err: unknown): Error {\n  if (err instanceof Error) return err;\n  // Chrome iOS / WKWebView: DOMException is not always `instanceof Error`, so\n  // a SecurityError from window.open / location assignment fell through to the\n  // synthetic \"threw non-Error: …\" branch below and titled its Sentry issue\n  // after the wrapper rather than the fault (WORLDMONITOR-11D). Keep the\n  // `[billing] <action>:` prefix every other error from this module carries —\n  // without it the same fault produces two differently-shaped titles depending\n  // on which branch caught it, and neither says where it happened.\n  if (typeof DOMException !== 'undefined' && err instanceof DOMException) {\n    return new Error(`[billing] ${action}: ${err.name}: ${err.message}`, { cause: err });\n  }\n  const rendered = err === undefined ? 'undefined' : String(err);\n  return new Error(`[billing] ${action} threw non-Error: ${rendered}`, { cause: err });\n}\n\nfunction requireSignedInUserId(action: string): string {\n  const userId = getCurrentClerkUser()?.id;\n  if (!userId) throw new Error(`Sign in to ${action}.`);\n  return userId;\n}\n\nasync function requireCurrentConvexUser(\n  userId: string,\n  action: string,\n): Promise<void> {\n  if (!await waitForConvexAuthForUser(userId)) {\n    throw new Error(`Account changed while ${action}. Try again.`);\n  }\n  assertAccountStillCurrent(userId, action);\n}\n\n/**\n * Initialize the subscription watch for the authenticated user.\n * Idempotent -- calling multiple times is a no-op after the first.\n * Failures are logged but never thrown (dashboard must not break).\n */","sourceCodeStart":59,"sourceCodeEnd":95,"githubUrl":"https://github.com/koala73/worldmonitor/blob/7d06c8633d256c18e38133030bc3613976a96ec9/src/services/billing.ts#L59-L95","documentation":"Error thrown by requireSignedInUserId in the browser billing service when no current Clerk user id is available — the visitor is not signed in. It is a generic auth precondition guard: any billing action named by the interpolated verb (open portal, invite seats, claim activation, …) requires an authenticated session first.","triggerScenarios":"Thrown at src/services/billing.ts:72 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Prompt the user to sign in via Clerk before retrying the billing action","Ensure the Clerk auth state is fully loaded before invoking billing service functions"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"7d06c8633d256c18e38133030bc3613976a96ec9","analyzedAt":"2026-08-21T16:51:25.751Z","contentChangedAt":"2026-08-21T16:51:25.751Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}