{"record":{"id":"33aa7150e520feee","repo":"koala73/worldmonitor","slug":"http-resp-status","errorCode":null,"errorMessage":"HTTP ${resp.status}","messagePattern":"HTTP \\$\\{resp\\.status\\}","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/components/GoldIntelligencePanel.ts","lineNumber":161,"sourceCode":"  return `<div style=\"flex:1;text-align:center;padding:4px;background:rgba(255,255,255,0.03);border-radius:4px\">\n    <div style=\"font-size:calc(9px * var(--wm-panel-effective-scale, 1));color:var(--text-dim)\">${escapeHtml(label)}</div>\n    <div style=\"font-size:calc(11px * var(--wm-panel-effective-scale, 1));font-weight:600;color:${color}\">${escapeHtml(fmtPct(pct, 1))}</div>\n  </div>`;\n}\n\nexport class GoldIntelligencePanel extends Panel {\n  private _hasData = false;\n\n  constructor() {\n    super({ id: 'gold-intelligence', title: t('panels.goldIntelligence'), infoTooltip: t('components.goldIntelligence.infoTooltip') });\n  }\n\n  public async fetchData(): Promise<boolean> {\n    this.showLoading();\n    try {\n      const url = toApiUrl('/api/market/v1/get-gold-intelligence');\n      const resp = await fetch(url);\n      if (!resp.ok) throw new Error(`HTTP ${resp.status}`);\n      const data: GoldIntelligenceData = await resp.json();\n\n      if (data.unavailable) {\n        if (!this._hasData) this.showError('Gold data unavailable', () => void this.fetchData());\n        return false;\n      }\n\n      if (!this.element?.isConnected) return false;\n      this._hasData = true;\n      this.render(data);\n      return true;\n    } catch (e) {\n      if (this.isAbortError(e)) return false;\n      if (!this.element?.isConnected) return false;\n      if (!this._hasData) this.showError(e instanceof Error ? e.message : 'Failed to load', () => void this.fetchData());\n      return false;\n    }\n  }","sourceCodeStart":143,"sourceCodeEnd":179,"githubUrl":"https://github.com/koala73/worldmonitor/blob/eeab0a219fce0f02a00603b532dbae9041b934ac/src/components/GoldIntelligencePanel.ts#L143-L179","documentation":"Generic non-OK marker thrown by GoldIntelligencePanel.fetchData() when the plain fetch to /api/market/v1/get-gold-intelligence returns a non-2xx status. The panel's catch renders an error state with a retry hook, so the number after 'HTTP ' is the Edge endpoint's status. Note this call uses plain fetch (no premiumFetch/Bearer), so auth-related 401/403 here means the endpoint itself rejected, not missing Pro headers.","triggerScenarios":"GET /api/market/v1/get-gold-intelligence returning 404 (function not deployed or wrong base path in local dev), 500/502/503 (upstream gold data source failing), 429 (rate limited), or a 401/403 from an access rule on the deployment.","commonSituations":"Running the Vite dev server without the Edge functions emulated, so /api/* 404s; the upstream market data provider outage or key quota exhausted surfacing as 5xx; deploying the frontend without the api/ functions; a CDN/WAF rule blocking the path.","solutions":["Open the network tab, confirm the exact status, and match it: 404 = endpoint missing (deploy functions / fix toApiUrl base), 5xx = upstream data source issue, 429 = rate limit","Retry via the panel's built-in retry (showError('Gold data unavailable', ...) wires a re-fetch button) after the underlying issue clears","If it persists, hit /api/market/v1/get-gold-intelligence directly in the browser to see the endpoint's own error body, and check the deployment includes api/market/v1/"],"exampleFix":"// before\nconst resp = await fetch(url);\nif (!resp.ok) throw new Error(`HTTP ${resp.status}`); // 'HTTP 503' with no context\n\n// after (surface the endpoint's own error body when present):\nconst resp = await fetch(url);\nif (!resp.ok) {\n  const detail = await resp.text().catch(() => '');\n  throw new Error(`HTTP ${resp.status}${detail ? `: ${detail.slice(0, 200)}` : ''}`);\n}","handlingStrategy":"retry","validationCode":"const url = toApiUrl('/api/market/v1/get-gold-intelligence');\n// probe deploy shape in dev before rendering the panel:\nconst head = await fetch(url, { method: 'HEAD' }).catch(() => null);\nif (head && head.status === 404) console.warn('gold endpoint not deployed on this origin');","typeGuard":null,"tryCatchPattern":"catch (e) { if (e instanceof Error && /^HTTP \\d+$/.test(e.message)) { const status = Number(e.message.slice(5)); if (status === 429 || status >= 500) scheduleRetry(backoffMs); else showError(e.message); } else throw e; }","preventionTips":["Confirm api/market/v1 functions are deployed on the same origin as the app","Classify by status: 404 deploy gap, 429 rate limit, 5xx upstream — different fixes","Keep the panel's retry affordance wired so transient failures self-heal"],"tags":["network","http-status","gold-intelligence","edge-api"],"backgroundTag":"http-error-status","analyzedSha":"eeab0a219fce0f02a00603b532dbae9041b934ac","analyzedAt":"2026-08-21T16:51:25.751Z","schemaVersion":2},"datasetVersion":"2026-08-23T13:39:53.451Z"}