Skip to content

Function: ruleRefusalOf()

@kortexya/reasoninglayer


@kortexya/reasoninglayer / 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.

unknown

What a catch received.

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.

Never. Anything that is not a rule refusal answers undefined.

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.

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;
}