Function: ruleRefusalOf()
@kortexya/reasoninglayer / ruleRefusalOf
Function: ruleRefusalOf()
Section titled “Function: ruleRefusalOf()”ruleRefusalOf(
error):RuleRefusal|undefined
Defined in: src/utils/rule-refusal.ts:40
Read the refusal of a rule replacement or withdrawal from the error the SDK threw for it.
Parameters
Section titled “Parameters”unknown
What a catch received.
Returns
Section titled “Returns”RuleRefusal | undefined
The refusal — status, code, message, the rule and, on
rule_holds_derivations, the derivation count — or undefined when
error is not a rule refusal.
Throws
Section titled “Throws”Never. Anything that is not a rule refusal answers undefined.
Remarks
Section titled “Remarks”The engine’s RuleRefusalResponse
({error, code, message, rule_id, derivations?, derivations_at_least?}),
answered by PUT and DELETE /api/v1/inference/rules/{id}. 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. See RuleRefusalCode for
every code.
Example
Section titled “Example”try { await client.inference.deleteRule(ruleId);} catch (error) { const refusal = ruleRefusalOf(error); if (refusal?.code === 'rule_holds_derivations') { console.log(`${refusal.derivations}${refusal.derivationsAtLeast ? '+' : ''} conclusions`); } else throw error;}