{"record":{"id":"2bfa3c1217a9bbd8","repo":"jackwener/OpenCLI","slug":"result-error-message","errorCode":null,"errorMessage":"result.error || message","messagePattern":"result\\.error \\|\\| message","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/geogebra/utils.js","lineNumber":63,"sourceCode":"    throw new ArgumentError(`${label} must be a ${positive ? 'positive ' : ''}finite number`);\n  }\n  return number;\n}\n\nexport function normalizeCoords(value) {\n  const parts = String(value ?? '').split(',').map(s => s.trim());\n  if (parts.length !== 2) {\n    throw new ArgumentError('coords must be in \"x,y\" format (e.g. \"1,2\")');\n  }\n  return parts.map((part, idx) => normalizeNumber(part, idx === 0 ? 'x' : 'y'));\n}\n\nexport function requireGgbSuccess(result, message) {\n  if (!isPlainObject(result)) {\n    throw new CommandExecutionError(`${message}: malformed GeoGebra result`);\n  }\n  if (!result.ok) {\n    throw new CommandExecutionError(result.error || message);\n  }\n  return result;\n}\n\n/**\n * Navigate to GeoGebra Geometry (if not already there) and wait for\n * the ggbApplet API to become available.\n */\nexport async function ensureApplet(page) {\n  let currentUrl = '';\n  try {\n    currentUrl = await page.getCurrentUrl();\n  } catch {\n    currentUrl = '';\n  }\n  // If already on the geometry page, check if applet is ready without re-navigating\n  if (currentUrl?.includes('geogebra.org/geometry')) {\n    try {","sourceCodeStart":45,"sourceCodeEnd":81,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/geogebra/utils.js#L45-L81","documentation":"When the GeoGebra bridge result is a well-formed object but result.ok is false, requireGgbSuccess() throws CommandExecutionError carrying the bridge's own error text (result.error), or falls back to the caller's generic message if the bridge supplied none. This is the standard path for GeoGebra command-level failures, not bridge/transport failures.","triggerScenarios":"ggbApplet.evalCommandGetLabels rejected the command: invalid GeoGebra syntax ('A=(1,2' with unbalanced parens), undefined object references ('Reflect(B)' where B does not exist), or the command returned false because the object name collides with an existing object of a different type.","commonSituations":"Typos in GeoGebra command names (case-sensitive: 'Midpoint' not 'midpoint'), referencing objects deleted earlier in the session, localized command names not accepted, or generating commands programmatically with unfilled placeholders like 'undefined'.","solutions":["Read the error detail (result.error) — it usually names the failing command or object.","Validate the GeoGebra command syntax against GeoGebra docs; commands are case-sensitive.","Ensure all referenced objects exist: run a listing of current objects or create prerequisites first.","Retry with a corrected command; use error text to drive programmatic correction of auto-generated commands."],"exampleFix":"// before\nawait ggbEval(page, 'midpoint(A,B)'); // error: midpoint not found\n// after\nawait ggbEval(page, 'Midpoint(A,B)');","handlingStrategy":"try-catch","validationCode":"// validate GeoGebra command syntax / referenced objects before executing\nif (/\\bundefined\\b/.test(cmd)) throw new Error('command contains unresolved placeholder');","typeGuard":"null","tryCatchPattern":"try { requireGgbSuccess(await ggbEval(page, cmd), 'Create point'); } catch (e) { console.error('GeoGebra rejected command:', e.message); /* fix cmd and retry */ }","preventionTips":["Match GeoGebra command capitalization exactly (Midpoint, not midpoint).","Check referenced objects exist before commands that use them.","Validate command names against current GeoGebra documentation.","Keep result.error text in logs — it names the failing construct."],"tags":["geogebra","command-execution","automation"],"backgroundTag":"command-execution-failed","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}