{"record":{"id":"cfca1c7ebce170ca","repo":"jackwener/OpenCLI","slug":"label-failed-error-message-error-cfca1c","errorCode":null,"errorMessage":"${label} failed: ${error?.message ?? error}","messagePattern":"(.+?) failed: (.+?)","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/hltv/utils.js","lineNumber":847,"sourceCode":"        });\n      }\n    }\n    return entries;\n  });\n\n  if (!Array.isArray(matrix)) return [];\n  return matrix;\n}\n\nexport async function gotoAndWait(page, url, selector, label) {\n  try {\n    await page.goto(url.toString(), { waitUntil: 'domcontentloaded', settleMs: 1000, timeout: 20000 });\n    await page.wait({ selector, timeout: 15000 });\n  } catch (error) {\n    if (/timeout/i.test(String(error?.message ?? error))) {\n      throw new TimeoutError(label, 15);\n    }\n    throw new CommandExecutionError(`${label} failed: ${error?.message ?? error}`);\n  }\n}\n\nexport function assertRows(rows, command) {\n  if (!Array.isArray(rows)) throw new CommandExecutionError(`${command} parser returned an unexpected shape`);\n  if (rows.length === 0) throw new EmptyResultError(command, 'No rows were found in the visible HLTV page');\n  return rows;\n}\n\nexport function assertRequiredFields(rows, command, fields) {\n  assertRows(rows, command);\n  for (const [index, row] of rows.entries()) {\n    for (const field of fields) {\n      if (row?.[field] === null || row?.[field] === undefined || row?.[field] === '') {\n        throw new CommandExecutionError(`${command} parser returned row ${index + 1} without required ${field}`);\n      }\n    }\n  }","sourceCodeStart":829,"sourceCodeEnd":865,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/hltv/utils.js#L829-L865","documentation":"The HLTV adapter wraps any failure from a page-fetch/parse helper (goto, selector wait, network, HTTP) into a CommandExecutionError whose message is `${label} failed: <cause>`. If the underlying error message matches /timeout/i it is re-thrown as a TimeoutError instead, so this message means a non-timeout failure while scraping an HLTV page.","triggerScenarios":"page.goto throws (DNS failure, connection refused, HTTP error, navigation aborted), page.wait times out with a non-'timeout'-worded message, or the page object itself errors during the scrape of a given command label.","commonSituations":"HLTV.org is down or blocking the scraper (Cloudflare/captcha), no network access in CI, an invalid or redirecting URL, or the headless browser crashes mid-navigation.","solutions":["Read the cause text after 'failed:' to identify the underlying error","Check general network connectivity and whether hltv.org loads in a browser","Retry later if HLTV is rate-limiting or serving a challenge page","If the cause is a selector/navigation issue, verify the target HLTV URL is valid"],"exampleFix":"// before\nconst rows = await fetchHltvRows(...);\n// after\ntry {\n  const rows = await fetchHltvRows(...);\n} catch (err) {\n  if (err instanceof TimeoutError) retryWithBackoff();\n  else console.error('HLTV command failed:', err.message);\n}","handlingStrategy":"try-catch","validationCode":"const url = new URL(target);\nif (url.hostname !== 'hltv.org' && url.hostname !== 'www.hltv.org') {\n  throw new Error('URL must be an hltv.org page');\n}\n// also: quick reachability probe\nconst probe = await fetch(url, { method: 'HEAD' }).catch(() => null);\nif (!probe || !probe.ok) throw new Error('hltv.org not reachable');","typeGuard":"function isCommandExecutionError(e) {\n  return e instanceof Error && e.name === 'CommandExecutionError';\n}","tryCatchPattern":"try {\n  const rows = await runHltvCommand(label, url);\n} catch (err) {\n  if (/timeout/i.test(String(err?.message))) {\n    return retryWithBackoff(() => runHltvCommand(label, url));\n  }\n  if (err.name === 'CommandExecutionError') {\n    console.error(`${label} failed: ${err.message} — check hltv.org reachability`);\n  }\n  throw err;\n}","preventionTips":["Pre-validate that URLs point at hltv.org before calling","Probe hltv.org reachability (HEAD request) before batch scrapes","Add backoff/retry for transient network and navigation failures","Run scrapes from networks that are not blocked by HLTV/Cloudflare"],"tags":["network","scraping","browser-automation"],"backgroundTag":"page-fetch-failed","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}