Class: OsfqlError
@kortexya/reasoninglayer / OsfqlError
Class: OsfqlError
Section titled “Class: OsfqlError”Defined in: src/errors.ts:959
An OSFQL program the engine refused or failed to run.
Remarks
Section titled “Remarks”Thrown by OsfqlClient.execute and OsfqlClient.preview for
every OsfqlErrorResponse body except a deadline. Narrow on
errorType:
parse/compile(HTTP 400) — rewrite the program;execution(HTTP 422) — it failed while running. When the failure is a typed write refusal, refusal carries the code and the concrete repairs. An engine before reasoninglayer#1041 also answers its authorization refusals here;- the authorization refusals of a mutation (reasoninglayer#1041), at the
status REST answers:
forbidden,operational_authority_denied,operational_authority_undetermined,term_sort_unresolved(HTTP 403);governed_sort_write_refused,authz_relation_derived(HTTP 409, with refusal);operational_rule_conclusion,authz_rule_shape,authz_parent_of_sort_refused(HTTP 422). A 403 here is anOsfqlError, not a ForbiddenError; - any other
error_type— a class added after this SDK: kept verbatim in errorType, with its refusal; row_cap(HTTP 422) — one materialisation outgrew maxRows; add aLIMIT, narrow the pattern, or send a largermaxRows. Nothing was written;refused(HTTP 400 / 404 / 409) — aDROP SORTthe guarded sort delete refused, or anALTER SORT … PARENTSmove the engine refused. AnALTER SORT … PARENTSthat names an unknown or foreign parent is a 400 refusal (Cannot reparent sort 'S': parent sort X does not exist), while an unknown subject sort stays anexecution422;lock_timeout(HTTP 503, OsfqlClient.execute only) — other writers kept the tenant’s knowledge base locked until the request deadline, and nothing ran. Retry the program as is, or send a largertimeoutMs. This error is anOsfqlError, not a ServiceUnavailableError: a caller that branched onServiceUnavailableErrorfor/osfqlmust branch onerrorType === 'lock_timeout'instead. The transport’s own 503 retry (retryOn503) still applies before this error is thrown.
A program abandoned at its timeoutMs deadline throws
DeadlineExceededError instead (HTTP 504, error_type: "timeout"),
because every route’s deadline answers that one contract.
A program with a DROP SORT or an ALTER SORT … PARENTS beside another
statement is refused (HTTP 400) before anything runs, with
atomicRefusal.code drop_sort_not_alone / alter_sort_not_alone
— the same code OsfqlClient.preview reports.
A refused DROP SORT (errorType: 'refused') carries the sort-delete
refusal in sortDeleteRefusal, as sortDeleteRefusalOf(error) reads it.
status, body and headers are those of the engine’s answer, as on every
ApiError; message is the engine’s own sentence.
Example
Section titled “Example”try { await client.osfql.execute('UPSERT customer(tier: "silver");');} catch (e) { if (e instanceof OsfqlError && e.refusal) { console.error(e.refusal.code, e.refusal.repairs[0]?.rewrite); } else if (e instanceof OsfqlError && e.errorType === 'row_cap') { console.error(`raise maxRows above ${e.maxRows}`); } else if (e instanceof OsfqlError && e.errorType === 'lock_timeout') { // the knowledge base stayed locked and nothing ran: retry as is } else if (e instanceof DeadlineExceededError) { // retry, or send a larger timeoutMs }}Extends
Section titled “Extends”Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new OsfqlError(
status,body,headers,failure):OsfqlError
Defined in: src/errors.ts:977
Parameters
Section titled “Parameters”status
Section titled “status”number
unknown
headers
Section titled “headers”Headers
failure
Section titled “failure”Returns
Section titled “Returns”OsfqlError
Overrides
Section titled “Overrides”Properties
Section titled “Properties”atomicRefusal
Section titled “atomicRefusal”
readonlyatomicRefusal:OsfqlAtomicRefusal|undefined
Defined in: src/errors.ts:975
Why the program was refused before anything ran — a DROP SORT or an
ALTER SORT … PARENTS beside another statement. Set only when
errorType is refused for that reason.
readonlybody:unknown
Defined in: src/errors.ts:58
Parsed response body.
Inherited from
Section titled “Inherited from”cause?
Section titled “cause?”
optionalcause?:unknown
Defined in: node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2022.error.d.ts:26
Inherited from
Section titled “Inherited from”component
Section titled “component”
readonlycomponent:string|undefined
Defined in: src/errors.ts:52
Health component that produced a structured refusal.
Inherited from
Section titled “Inherited from”errorCode
Section titled “errorCode”
readonlyerrorCode:string|undefined
Defined in: src/errors.ts:56
Backend error code (from response body error field), if present.
Inherited from
Section titled “Inherited from”errorType
Section titled “errorType”
readonlyerrorType:OsfqlErrorType
Defined in: src/errors.ts:963
The class of the failure (error_type on the wire).
headers
Section titled “headers”
readonlyheaders:Headers
Defined in: src/errors.ts:60
Response headers.
Inherited from
Section titled “Inherited from”maxRows
Section titled “maxRows”
readonlymaxRows:number|undefined
Defined in: src/errors.ts:967
The row cap the program ran under. Set only when errorType is row_cap.
message
Section titled “message”message:
string
Defined in: node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es5.d.ts:1077
Inherited from
Section titled “Inherited from”name:
string='OsfqlError'
Defined in: src/errors.ts:960
Overrides
Section titled “Overrides”refusal
Section titled “refusal”
readonlyrefusal:OsfqlRefusal|undefined
Defined in: src/errors.ts:965
The typed write refusal, when the failure is one.
sortDeleteRefusal
Section titled “sortDeleteRefusal”
readonlysortDeleteRefusal:SortDeleteRefusalDto|undefined
Defined in: src/errors.ts:969
The coded refusal of a DROP SORT. Set only when errorType is refused.
stack?
Section titled “stack?”
optionalstack?:string
Defined in: node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es5.d.ts:1078
Inherited from
Section titled “Inherited from”status
Section titled “status”
readonlystatus:number
Defined in: src/errors.ts:54
HTTP status code.
Inherited from
Section titled “Inherited from”stackTraceLimit
Section titled “stackTraceLimit”
staticstackTraceLimit:number
Defined in: node_modules/.pnpm/@types+node@24.13.3/node_modules/@types/node/globals.d.ts:68
The Error.stackTraceLimit property specifies the number of stack frames
collected by a stack trace (whether generated by new Error().stack or
Error.captureStackTrace(obj)).
The default value is 10 but may be set to any valid JavaScript number. Changes
will affect any stack trace captured after the value has been changed.
If set to a non-number value, or set to a negative number, stack traces will not capture any frames.
Inherited from
Section titled “Inherited from”Methods
Section titled “Methods”captureStackTrace()
Section titled “captureStackTrace()”
staticcaptureStackTrace(targetObject,constructorOpt?):void
Defined in: node_modules/.pnpm/@types+node@24.13.3/node_modules/@types/node/globals.d.ts:52
Creates a .stack property on targetObject, which when accessed returns
a string representing the location in the code at which
Error.captureStackTrace() was called.
const myObject = {};Error.captureStackTrace(myObject);myObject.stack; // Similar to `new Error().stack`The first line of the trace will be prefixed with
${myObject.name}: ${myObject.message}.
The optional constructorOpt argument accepts a function. If given, all frames
above constructorOpt, including constructorOpt, will be omitted from the
generated stack trace.
The constructorOpt argument is useful for hiding implementation
details of error generation from the user. For instance:
function a() { b();}
function b() { c();}
function c() { // Create an error without stack trace to avoid calculating the stack trace twice. const { stackTraceLimit } = Error; Error.stackTraceLimit = 0; const error = new Error(); Error.stackTraceLimit = stackTraceLimit;
// Capture the stack trace above function b Error.captureStackTrace(error, b); // Neither function c, nor b is included in the stack trace throw error;}
a();Parameters
Section titled “Parameters”targetObject
Section titled “targetObject”object
constructorOpt?
Section titled “constructorOpt?”Function
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”prepareStackTrace()
Section titled “prepareStackTrace()”
staticprepareStackTrace(err,stackTraces):any
Defined in: node_modules/.pnpm/@types+node@24.13.3/node_modules/@types/node/globals.d.ts:56
Parameters
Section titled “Parameters”Error
stackTraces
Section titled “stackTraces”CallSite[]
Returns
Section titled “Returns”any
https://v8.dev/docs/stack-trace-api#customizing-stack-traces