Skip to content

Function: sortDeleteRefusalOf()

@kortexya/reasoninglayer


@kortexya/reasoninglayer / sortDeleteRefusalOf

sortDeleteRefusalOf(error): SortDeleteRefusalDto | undefined

Defined in: src/utils/sort-delete-refusal.ts:126

Read the refusal of a sort delete from the error the SDK threw for it.

unknown

What a catch received.

SortDeleteRefusalDto | undefined

The refusal — status, code, message and the rules it names — or undefined when error is not the refusal of a sort delete.

Never. Anything that is not a sort-delete refusal answers undefined.

A sort delete is refused on two surfaces, with the same codes:

  • SortsClient.deleteSort throws an ApiError whose body is {error, code, message, sort_id, rules?}. The status is the error’s HTTP status.
  • OSFQL DROP SORT through OsfqlClient throws an ApiError whose body is {error_type: "refused", message, sort_delete_refusal}.

Both are read into one SortDeleteRefusalDto. The body is the raw wire (snake_case), so the rules are read field by field: a body that does not have the shape answers undefined rather than a refusal with holes in it.

code is the contract; the prose of message is not. See SortDeleteRefusalDto for every code.

try {
await client.sorts.deleteSort(sortId);
} catch (error) {
const refusal = sortDeleteRefusalOf(error);
if (refusal === undefined) throw error;
if (refusal.code === 'sort_holds_terms') {
await client.sorts.deleteSort(sortId, { terms: 'delete' });
}
}