{"record":{"id":"dbcd3e463466baca","repo":"jackwener/OpenCLI","slug":"label-failed-error-message-error","errorCode":null,"errorMessage":"${label} failed: ${error?.message ?? error}","messagePattern":"(.+?) failed: (.+?)","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/_shared/search-adapter.js","lineNumber":68,"sourceCode":"  try {\n    const url = new URL(raw, baseUrl);\n    if (url.protocol !== 'http:' && url.protocol !== 'https:') return '';\n    return url.href;\n  } catch {\n    return '';\n  }\n}\n\nexport function emptySearchResults(site, query) {\n  return new EmptyResultError(`${site} search`, `No ${site} results matched \"${query}\".`);\n}\n\nexport async function runBrowserStep(label, fn) {\n  try {\n    return await fn();\n  } catch (error) {\n    if (error?.code || error?.name === 'ArgumentError') throw error;\n    throw new CommandExecutionError(`${label} failed: ${error?.message ?? error}`);\n  }\n}\n","sourceCodeStart":50,"sourceCodeEnd":71,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/_shared/search-adapter.js#L50-L71","documentation":"runBrowserStep wraps an async browser step (page.goto, page.evaluate, etc.) and converts any thrown error into a CommandExecutionError labeled '<label> failed: <original message>'. Errors that already look like library errors (having a code, or being an ArgumentError by name) are re-thrown unchanged. So this message means the underlying browser automation step failed for a non-library reason.","triggerScenarios":"Any rejection inside the wrapped fn: navigation timeout, net::ERR_NAME_NOT_RESOLVED, page closed/crashed, or a JS exception inside page.evaluate — as long as the error lacks a .code and is not an ArgumentError.","commonSituations":"Site is down or blocking (403/captcha), DNS/proxy misconfiguration, headless browser crashes on heavy pages, navigation timeouts on slow networks, evaluate script throwing a TypeError in page context.","solutions":["Read the original message after 'failed:' — it names the root cause (timeout, DNS, blocked).","Retry the command; transient network/captcha failures often resolve.","Check connectivity/proxy settings and whether the site blocks headless browsers.","Increase any timeout options or re-run in foreground/non-headless mode; keep the browser session alive via the site's login command if auth-gated."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// pre-check connectivity/site reachability\nconst res = await fetch(siteUrl, { method: 'HEAD' }).catch(() => null);\nif (!res || !res.ok) console.warn('Site may be unreachable or blocked');","typeGuard":null,"tryCatchPattern":"try {\n  await runSearchCommand();\n} catch (e) {\n  if (e instanceof CommandExecutionError && e.message.includes('failed:')) {\n    const cause = e.message.split('failed:')[1]?.trim();\n    console.error(`Browser step failed: ${cause}; retrying may help`);\n  } else throw e;\n}","preventionTips":["Retry transient failures (timeouts, DNS) with backoff","Check network/proxy and whether the site blocks headless browsers","Read the root cause embedded after 'failed:' before changing code","Run auth/login commands first for gated sites"],"tags":["browser","network","error-wrapping"],"backgroundTag":"browser-step-failed","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}