Function: sortDeleteRefusalOf()
@kortexya/reasoninglayer / sortDeleteRefusalOf
Function: sortDeleteRefusalOf()
Section titled “Function: 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.
Parameters
Section titled “Parameters”unknown
What a catch received.
Returns
Section titled “Returns”SortDeleteRefusalDto | undefined
The refusal — status, code, message and the rules it names — or
undefined when error is not the refusal of a sort delete.
Throws
Section titled “Throws”Never. Anything that is not a sort-delete refusal answers
undefined.
Remarks
Section titled “Remarks”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 SORTthrough 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.
Example
Section titled “Example”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' }); }}