Skip to content

Function: functionRefusalOf()

@kortexya/reasoninglayer


@kortexya/reasoninglayer / functionRefusalOf

functionRefusalOf(error): FunctionRefusal | undefined

Defined in: src/utils/function-refusal.ts:49

Read the refusal of a function registration, evaluation, read, replacement or withdrawal from the error the SDK threw for it.

unknown

What a catch received.

FunctionRefusal | undefined

The refusal — status, code, message, the function and, on function_has_callers, its callers — or undefined when error is not a function refusal.

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

The engine’s FunctionRefusalResponse ({error, code, message, function, callers?}). 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 FunctionRefusalCode for every code.

try {
await client.functions.deleteFunction('discount');
} catch (error) {
const refusal = functionRefusalOf(error);
if (refusal?.code === 'function_has_callers') {
console.log(refusal.callers.map((c) => c.name));
} else throw error;
}