MCPcopy Index your code
hub / github.com/GitbookIO/gitbook / throwIfDataError

Function throwIfDataError

packages/gitbook/src/lib/data/errors.ts:20–31  ·  view source on GitHub ↗
(
    response: DataFetcherResponse<T> | Promise<DataFetcherResponse<T>>
)

Source from the content-addressed store, hash-verified

18export function throwIfDataError<T>(response: DataFetcherResponse<T>): T;
19export function throwIfDataError<T>(response: Promise<DataFetcherResponse<T>>): Promise<T>;
20export function throwIfDataError<T>(
21 response: DataFetcherResponse<T> | Promise<DataFetcherResponse<T>>
22): T | Promise<T> {
23 if (response instanceof Promise) {
24 return response.then((result) => throwIfDataError(result));
25 }
26
27 if (response.error) {
28 throw new DataFetcherError(response.error.message, response.error.code);
29 }
30 return response.data;
31}
32
33/**
34 * Get the data from the response or null if there is an "Not found" error.

Callers 9

withAPITokenFunction · 0.90
streamAskQuestionFunction · 0.90
searchSiteContentFunction · 0.90
getMarkdownForPageFunction · 0.90
getNodesFromSiteSpacesFunction · 0.90
fetchSiteContextByIdsFunction · 0.90
fetchSpaceContextByIdsFunction · 0.90
handlerFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected