jackwener/OpenCLI · error · CommandExecutionError

result.error || message

Error message

result.error || message

What it means

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.

Source

Thrown at clis/geogebra/utils.js:63

    throw new ArgumentError(`${label} must be a ${positive ? 'positive ' : ''}finite number`);
  }
  return number;
}

export function normalizeCoords(value) {
  const parts = String(value ?? '').split(',').map(s => s.trim());
  if (parts.length !== 2) {
    throw new ArgumentError('coords must be in "x,y" format (e.g. "1,2")');
  }
  return parts.map((part, idx) => normalizeNumber(part, idx === 0 ? 'x' : 'y'));
}

export function requireGgbSuccess(result, message) {
  if (!isPlainObject(result)) {
    throw new CommandExecutionError(`${message}: malformed GeoGebra result`);
  }
  if (!result.ok) {
    throw new CommandExecutionError(result.error || message);
  }
  return result;
}

/**
 * Navigate to GeoGebra Geometry (if not already there) and wait for
 * the ggbApplet API to become available.
 */
export async function ensureApplet(page) {
  let currentUrl = '';
  try {
    currentUrl = await page.getCurrentUrl();
  } catch {
    currentUrl = '';
  }
  // If already on the geometry page, check if applet is ready without re-navigating
  if (currentUrl?.includes('geogebra.org/geometry')) {
    try {

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Read the error detail (result.error) — it usually names the failing command or object.
  2. Validate the GeoGebra command syntax against GeoGebra docs; commands are case-sensitive.
  3. Ensure all referenced objects exist: run a listing of current objects or create prerequisites first.
  4. Retry with a corrected command; use error text to drive programmatic correction of auto-generated commands.

Example fix

// before
await ggbEval(page, 'midpoint(A,B)'); // error: midpoint not found
// after
await ggbEval(page, 'Midpoint(A,B)');
Defensive patterns

Strategy: try-catch

Validate before calling

// validate GeoGebra command syntax / referenced objects before executing
if (/\bundefined\b/.test(cmd)) throw new Error('command contains unresolved placeholder');

Type guard

null

Try / catch

try { requireGgbSuccess(await ggbEval(page, cmd), 'Create point'); } catch (e) { console.error('GeoGebra rejected command:', e.message); /* fix cmd and retry */ }

Prevention

When it happens

Trigger: 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.

Common situations: 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'.

Related errors


AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29). Data as JSON: /api/errors/2bfa3c1217a9bbd8. Report an issue: GitHub.