TypeScript / JavaScript
MaelysDatalogError
Error class, status values and diagnostics.The constructor example uses session and input from the full program and wraps a real copied diagnostic.
Class: MaelysDatalogError
TypeScript · exceptionSince v0.15.0
MaelysDatalogErrorDeclaration
class MaelysDatalogError extends ErrorAn operation failure with its status and an immutable copied diagnostic.
Creation and access
- constructor
new MaelysDatalogError(operation, status, diagnostic)Construct an error carrying the failed operation, status and diagnostic.
- thrown by
Native binding operationsCatch an operation failure to inspect its immutable copied diagnostic; a false query answer is a successful result.
Attributes
codenumberreadonly field
Alias of the operation status on MaelysDatalogError; diagnostic.code is the separate engine diagnostic code.
statusnumberreadonly field
Stable numeric operation status.
Immutable copied structured diagnostic.
Constructor: MaelysDatalogError()
TypeScript · constructorSince v0.15.0
MaelysDatalogError.constructornew MaelysDatalogError(
operation: string,
status: number,
diagnostic: Diagnostic
): MaelysDatalogErrorConstruct an error carrying the failed operation, status and diagnostic.
Arguments
operationstring
Name of the failed binding operation.
statusnumber
Stable numeric operation status.
diagnosticDiagnostic
Copied structured engine diagnostic.
Return value
MaelysDatalogErrorReturns an exception object with the supplied operation context, status and copied diagnostic. Construction does not execute a native operation.
try {
input.addFact('owns', ['alice', 'roadmap.pdf'])
throw new Error('Expected PAYLOAD_TOO_LARGE from the full input buffer')
} catch (cause) {
if (!(cause instanceof MaelysDatalogError)) throw cause
if (cause.status !== Status.PAYLOAD_TOO_LARGE) throw cause
const error = new MaelysDatalogError('authorize request', cause.status, cause.diagnostic)
console.log('status:', error.status)
console.log('message:', error.message)
} finally {
engine.close()
}status: -12 message: authorize request: payload_too_large: Fact 0: predicate rejected: input EDB text capacity exhausted (including NUL terminators).
Interfaces
Limits · Diagnostic.
Limits
TypeScript · interfaceSince v0.10.0
LimitsBuild-time engine bounds for the selected SMALL or LARGE profile.
Creation and access
- read from
engine.limitsRead the selected engine profile’s fixed build-time bounds.
Fields
maxSymbolsnumberfield
Maximum interned symbols.
stringPoolBytesnumberfield
Bytes in the engine string pool.
maxPredicatesnumberfield
Maximum registered predicates.
maxRulesnumberfield
Maximum compiled rules.
maxAritynumberfield
Maximum predicate arity.
maxBodyLiteralsnumberfield
Maximum literals in one rule body.
maxDepthnumberfield
Maximum supported engine depth.
maxEdbFactsnumberfield
Maximum runtime input facts.
maxIdbFactsnumberfield
Maximum derived facts.
maxFactsPerPrednumberfield
Maximum facts per predicate.
maxStringBytesnumberfield
Maximum bytes in one string.
inputEdbTextBytesnumberfield
Default text capacity of the input buffer.
maxPolicyAtomsnumberSince v0.16.0field
Maximum declared policy-source atoms.
maxPolicyAtomBytesnumberSince v0.16.0field
Maximum UTF-8 bytes across policy atoms, excluding NUL terminators.
Diagnostic
TypeScript · interfaceSince v0.10.0
DiagnosticAn immutable copied diagnostic. Optional fields appear only when the engine supplies their presence bits.
Creation and access
- read from
error.diagnosticRead the structured diagnostic copied from the failed operation.
Fields
statusnumberreadonly field
Stable numeric operation status.
sourcenumberreadonly field
Numeric diagnostic source.
codenumberreadonly field
Native diagnostic code; distinct from the operation status.
presentbigintreadonly field
Presence-bit mask describing available structured fields.
phasestringreadonly field
Phase during which the operation failed.
messagestringreadonly field
Human-readable diagnostic detail copied from the engine.
hintstringreadonly field
Suggested corrective action when supplied.
codeNamestringreadonly field
Stable diagnostic code name.
statusNamestringreadonly field
Stable operation status name.
location?Readonly<{ line: number; column: number; file: string }>readonly field
Optional source file, line and column.
predicate?Readonly<{ name: string; arity: number }>readonly field
Optional predicate name and arity.
capacity?Readonly<{ observed: number; limit: number; kind: number; name?: string | null }>readonly field
Optional attempted value and applicable bound, with its numeric budget kind and, when supplied, its public budget name.
depth?Readonly<{ observed: number; limit: number }>readonly field
Optional observed depth and bound.
comparison?Readonly<{ result: number; expectedKind: number; lhsKind: number; rhsKind: number; op: number }>readonly field
Optional operand kinds and comparison outcome.
arity?Readonly<{ expected: number; observed: number; termIndex: number }>readonly field
Optional expected and observed arity and term index.
rule?Readonly<{ id: number }>readonly field
Optional rule identifier.
aggregate?Readonly<{ operator: string; value: string; valueKind: number; termIndex: number; limit: number }>readonly field
Optional aggregate operation, exact textual operand and bound.
context?Readonly<{ token: string; field: string; domain: string }>readonly field
Optional token, field and domain context.
try {
engine.loadInlineRuleset('documents', 'too-many-rules',
`${documentPolicy}\n`.repeat(engine.limits.maxRules + 1))
throw new Error('Expected a rule-capacity failure')
} catch (error) {
if (!(error instanceof MaelysDatalogError)) throw error
if (!error.diagnostic.capacity) throw error
console.log('status:', error.diagnostic.statusName)
console.log('budget kind:', error.diagnostic.capacity.kind)
console.log('budget name:', error.diagnostic.capacity.name)
} finally { engine.close() }status: payload_too_large budget kind: 4 budget name: MAX_RULES
Objects
Status
TypeScript · objectSince v0.10.0
StatusStable operation status values. A false query answer is successful and is not an error status.
Members
OK0
Operation succeeded.
INVALID_ ARGUMENT-1
Malformed argument.
INVALID_ FIELD-2
Invalid field or typed value.
NOT_ FOUND-3
Requested item or explanation symbol not found.
NOT_ IMPLEMENTED-4
Operation not implemented.
UNSUPPORTED-5
Unsupported capability or operation.
TIMEOUT-6
Operation timed out.
IO-7
Input/output failure.
INTERNAL-8
Internal operation failure.
UNAUTHORIZED-9
Authentication required.
FORBIDDEN-10
Permission or manifest policy rejects the operation.
RATE_ LIMITED-11
Rate limit reached.
PAYLOAD_ TOO_ LARGE-12
Content exceeds an engine bound.
INVALID_ STATE-13
Resource is closed or its current lease prevents the operation.
STORAGE_ TOO_ SMALL-14
Supplied storage is insufficient.
Usage guides
The examples are now in the Errors guide.