Skip to content

Errors and Results

Daniele Zucchelli edited this page Aug 16, 2026 · 2 revisions

Single request

type CompileExecutionResult<T = any> = {
  ok: boolean;
  data?: T[];
  error?: unknown[] | unknown;
};

compile() returns a plan. When execute() succeeds, it returns { ok: true, data }. An execution error is caught and returned as { ok: false, error }.

Errors thrown during initial compilation or plan construction may occur before the result envelope exists, so callers should guard both compile and execute while the API is experimental.

try {
  const plan = await compile(db, request, user, role, structure);
  const result = await plan.execute();
  if (!result.ok) return handleFailure(result.error);
  return result.data;
} catch (error) {
  return handleFailure(error);
}

Phase results

A QUERY phase returns an object with ok, collected data, and an optional array of errors. A TRANSACTION phase returns all results on commit or one error on rollback. A multi-phase request nests these phase results in top-level data.

Current error categories

The implementation throws generic Error instances for cases including:

  • unknown table or field;
  • missing endpoint;
  • unsupported role or malformed permissions;
  • empty permission set;
  • unsupported operation, join type, operator, or phase mode;
  • missing mutation data;
  • invalid condition shape;
  • rejected policy condition.

These messages are developer diagnostics, not a stable public API.

Application mapping

Map internal failures to a small API contract such as FORBIDDEN, INVALID_REQUEST, NOT_FOUND, and INTERNAL_ERROR. Do not infer authorization semantics from the message string in durable application logic.

← DSL Reference · Troubleshooting →

Clone this wiki locally