{"record":{"id":"7bc0d043d23ad538","repo":"jackwener/OpenCLI","slug":"failed-to-capture-geogebra-screenshot-err-mes","errorCode":null,"errorMessage":"`Failed to capture GeoGebra screenshot: ${err?.message || err}`","messagePattern":"`Failed to capture GeoGebra screenshot: (.+?)`","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/geogebra/hexagon.js","lineNumber":52,"sourceCode":"      ['V4', `(-${size},0)`],\n      ['V5', `(${size}*cos(4*pi/3),${size}*sin(4*pi/3))`],\n      ['V6', `(${size}*cos(5*pi/3),${size}*sin(5*pi/3))`],\n    ];\n    for (const [name, coords] of vertices) {\n      const result = requireGgbSuccess(await ggbEval(page, `${name}=${coords}`), `Failed to create point ${name}`);\n      results.push({ step: `${name}=${coords}`, result: `ok (${result.label || name})` });\n    }\n\n    const polygon = requireGgbSuccess(await ggbEval(page, 'Hexagon=Polygon(V1,V2,V3,V4,V5,V6)'), 'Failed to create hexagon polygon');\n    results.push({ step: 'Hexagon=Polygon(V1,V2,V3,V4,V5,V6)', result: `ok (${polygon.label || 'hexagon created'})` });\n\n    const objectCount = await ggbWaitForObjectCount(page, 7);\n    const objects = await ggbListObjects(page);\n    const screenshotPath = path.join(os.tmpdir(), 'opencli-geogebra-hexagon.png');\n    try {\n      await page.screenshot({ path: screenshotPath });\n    } catch (err) {\n      throw new CommandExecutionError(`Failed to capture GeoGebra screenshot: ${err?.message || err}`);\n    }\n\n    if (Array.isArray(objects) && objects.length > 0) {\n      results.push({ step: `canvas has ${objectCount} objects`, result: objects.map(o => `${o.name}(${o.type})`).join(', ') });\n    }\n    results.push({ step: 'screenshot', result: screenshotPath });\n\n    return results;\n  },\n});\n","sourceCodeStart":34,"sourceCodeEnd":63,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/geogebra/hexagon.js#L34-L63","documentation":"CommandExecutionError thrown when page.screenshot() fails while capturing the GeoGebra canvas for the hexagon demo. The original error's message is embedded so the underlying capture failure (browser, file write, or session issue) is visible.","triggerScenarios":"The screenshot call at clis/geogebra/hexagon.js:52 throws — e.g. the page/tab closed mid-run, the browser context ended, or the output path in os.tmpdir() is not writable.","commonSituations":"Headless browser crashed or disconnected; tmp directory permissions; screenshot attempted after navigation destroyed the target; disk full.","solutions":["Re-run the command; screenshot failures are often transient","Verify the temp directory (os.tmpdir()) is writable and has space","Ensure the applet page/browser stays open through the run; update browser/automation deps if the session keeps dying"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"const tmp = os.tmpdir();\nfs.accessSync(tmp, fs.constants.W_OK); // throws early if tmp is not writable","typeGuard":null,"tryCatchPattern":"try {\n  await page.screenshot({ path: screenshotPath });\n} catch (err) {\n  console.error(`Screenshot failed: ${err?.message || err}`);\n  // retry once after a short wait, then continue without the screenshot\n}","preventionTips":["Keep the browser/page alive until after the screenshot","Check tmp dir writability and free disk space","Retry once — capture failures are frequently transient"],"tags":["screenshot","browser-automation","geogebra"],"backgroundTag":"screenshot-capture-failed","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}