TypeScript / JavaScript
Errors
Read structured native diagnostics and fixed build limits.Native failures become JavaScript exceptions. A false ground query is an
ordinary negative answer; malformed input or a failed solve instead throws.
Diagnostics
Native failures throw DatalogError with the returned status and an immutable
diagnostic snapshot. The snapshot includes statusName, precise code and
codeName, source, the bigint presence mask, and message/phase/hint strings.
Optional sections include location, predicate, capacity, depth, comparison,
arity, rule and context. Sections may coexist; absent fields are not meaningful
zeros. Errors from operations without a diagnostic do not reuse old messages.
try {
pg.solve()
} catch (error) {
if (error instanceof DatalogError) {
const d = error.diagnostic
console.error(d.codeName, d.predicate?.name,
d.capacity?.observed, d.capacity?.limit)
}
throw error
}A SMALL predicate overflow can report 65 / 64 and the predicate together.
Read these values from the diagnostic: LARGE has a different bound.
The published declaration also gives Diagnostic optional aggregate and
context sections. Test a section's presence before reading its fields;
the present mask says which native sections were actually supplied.
Build limits
The published Limits type names the values in this snapshot.
buildLimits() returns the compiled limits: symbols, string pool bytes,
predicates, rules, arity, body literals, depth, EDB facts, IDB facts, facts per
predicate, maximum string bytes and input text bytes. SMALL and LARGE remain
fixed-capacity engine profiles. Emscripten memory growth does not create an
elastic engine profile or promise a browser memory ceiling.
const limits = pg.buildLimits()
console.log(limits.maxEdbFacts, limits.inputEdbTextBytes)Read the active module's limits rather than copying a capacity from an example or from another profile. A failed solve publishes no partial result.