TypeScript / JavaScript
Errors guide
Examples and practical guidance for the JavaScript and TypeScript MaelysDatalogError API.The MaelysDatalogError reference contains the complete class and method cards.
Usage and examples
engine.limits describes build bounds. maxPolicyAtoms and
maxPolicyAtomBytes bound the policy vocabulary; they are separate from
rules.programCounts(), session quotas and current input occupancy.
Separate answers from failures
| Outcome | Application meaning |
|---|---|
containsFact(...) returns false | A valid query has no matching fact |
TypeError or RangeError | A JavaScript value or option fails wrapper validation |
MaelysDatalogError | An engine operation or binding lifecycle requirement failed |
An explanation returns status=truncated | A bounded document was returned successfully |
Handle failures at the operation boundary, and release resources through
finally even when reporting an error:
import { MaelysDatalogError, Status } from '@maelys-dev/datalog/wasm'
try {
const result = session.solve(input)
try {
console.log(result.containsFact('allow', ['alice', 'roadmap.pdf']))
} finally {
result.close()
}
} catch (error) {
if (error instanceof MaelysDatalogError) {
const d = error.diagnostic
console.error(error.status, d.codeName, d.message)
if (error.status === Status.PAYLOAD_TOO_LARGE && d.capacity) {
console.error(d.capacity.observed, d.capacity.limit)
}
}
throw error
}The diagnostic is a copied immutable snapshot. Its optional location, predicate, capacity and other sections may coexist; read them only when present. Later operations do not overwrite an earlier error's diagnostic.
Correct the cause before retrying
| Status | Typical corrective action |
|---|---|
INVALID_STATE | Check closed owners, a live result on the session, or an EDB still frozen after a successful solve |
PAYLOAD_TOO_LARGE | Inspect the reported capacity and choose an admissible request or suitable new resource capacities |
STORAGE_TOO_SMALL | Treat insufficient workspace/storage as an operation failure, not as a successfully truncated document |
UNSUPPORTED | Check the selected runtime and backend, such as a filesystem path in WASM or a nonzero reference-backend work limit |
NOT_FOUND | Check the requested policy or result symbol; explanation symbol lookup is stricter than a negative membership query |
FORBIDDEN | Check manifest loading permissions rather than enabling them implicitly |
engine.limits gives the profile's compiled bounds, input.usage reports current
input occupancy, and session.capacities gives the session's chosen quotas.
They answer different questions. Creating a LARGE Engine does not migrate an
existing SMALL Engine's resources, and WASM memory growth does not make solver
capacities unbounded.