Skip to main content

Function: apiErrorResult()

apiErrorResult(error): object & object

Defined in: apiError.ts:117

The tool result for a failed REST answer: isError: true, the error's message as text, and structuredContent: { status, error }, where error is the body's error object unchanged (code, message, meta, hint, docs_url, …). A body with no error object carries status alone.

registerTools applies it to an ApiError a tool throws; call it yourself in a handler registered with server.registerTool directly.

Parameters​

ParameterType
errorApiError

Returns​

object & object

Example​

try {
return jsonResult(await apiCall('POST', '/tasks', { body }));
} catch (error) {
if (isApiError(error)) return apiErrorResult(error);
throw error;
}