Function: termRefusalOf()
@kortexya/reasoninglayer / termRefusalOf
Function: termRefusalOf()
Section titled “Function: termRefusalOf()”termRefusalOf(
error):TermRefusal|undefined
Defined in: src/utils/term-refusal.ts:118
Read the refusal of a term write from the error the SDK threw for it.
Parameters
Section titled “Parameters”unknown
What a catch received.
Returns
Section titled “Returns”TermRefusal | undefined
The refusal — status, code, message, the term, its referrers, the
repairs, the rules that hold it and the rule that derived it — or
undefined when error is not a term refusal.
Throws
Section titled “Throws”Never. Anything that is not a term refusal answers undefined.
Remarks
Section titled “Remarks”The engine’s TermRefusalResponse
({error, code, message, term_id, referrers?, repairs?, rule_ids?, derived_by?}),
answered by DELETE and PUT /api/v1/terms/{id} and by
POST /api/v1/inference/facts/bulk-retract. A
DerivedFactWriteError is one too (code: "write_targets_derived_fact").
The body is the raw wire (snake_case), so every field is read and checked: a
body that does not have the shape answers undefined rather than a refusal
with holes in it. See TermRefusalCode for every code.
Example
Section titled “Example”try { await client.terms.deleteTerm(termId);} catch (error) { const refusal = termRefusalOf(error); if (refusal?.code === 'term_has_referrers') { console.log(refusal.referrers.map((r) => r.displayName ?? r.termId)); } else throw error;}