{"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":84,"sourceCode":"  // 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    const wrapped = new Error(`[billing] ${action}: ${err.name}: ${err.message}`);\n    (wrapped as Error & { cause?: unknown }).cause = err;\n    return wrapped;\n  }\n  const rendered = err === undefined ? 'undefined' : String(err);\n  const wrapped = new Error(`[billing] ${action} threw non-Error: ${rendered}`);\n  // Attach the original thrown value as `cause` so Sentry shows it as structured data.\n  // Assigned post-construction because tsconfig target=ES2020 lacks ErrorOptions typing;\n  // Sentry and modern browsers read the property either way.\n  (wrapped as Error & { cause?: unknown }).cause = err;\n  return wrapped;\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":66,"sourceCodeEnd":102,"githubUrl":"https://github.com/koala73/worldmonitor/blob/9361220cc013571781071f0206e4d80fd14b2f7f/src/services/billing.ts#L66-L102","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":"9361220cc013571781071f0206e4d80fd14b2f7f","analyzedAt":"2026-08-21T16:51:25.751Z","contentChangedAt":"2026-08-21T16:51:25.751Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}