Skip to content

Commit 5b010da

Browse files
algolia-botFluf22millotp
committed
chore: generated code for commit a68907d1. [skip ci]
algolia/api-clients-automation@a68907d Co-authored-by: algolia-bot <[email protected]> Co-authored-by: Thomas Raffray <[email protected]> Co-authored-by: Pierre Millot <[email protected]>
1 parent 6946474 commit 5b010da

File tree

1 file changed

+21
-14
lines changed

1 file changed

+21
-14
lines changed

Diff for: packages/client-search/src/searchClient.ts

+21-14
Original file line numberDiff line numberDiff line change
@@ -320,18 +320,19 @@ export function createSearchClient({
320320
Math.min(retryCount * 200, 5000),
321321
}: WaitForApiKeyOptions,
322322
requestOptions?: RequestOptions
323-
): Promise<ApiError | GetApiKeyResponse> {
323+
): Promise<GetApiKeyResponse | undefined> {
324324
let retryCount = 0;
325-
const baseIteratorOptions: IterableOptions<ApiError | GetApiKeyResponse> =
326-
{
327-
aggregator: () => (retryCount += 1),
328-
error: {
329-
validate: () => retryCount >= maxRetries,
330-
message: () =>
331-
`The maximum number of retries exceeded. (${retryCount}/${maxRetries})`,
332-
},
333-
timeout: () => timeout(retryCount),
334-
};
325+
const baseIteratorOptions: IterableOptions<
326+
GetApiKeyResponse | undefined
327+
> = {
328+
aggregator: () => (retryCount += 1),
329+
error: {
330+
validate: () => retryCount >= maxRetries,
331+
message: () =>
332+
`The maximum number of retries exceeded. (${retryCount}/${maxRetries})`,
333+
},
334+
timeout: () => timeout(retryCount),
335+
};
335336

336337
if (operation === 'update') {
337338
if (!apiKey) {
@@ -366,9 +367,15 @@ export function createSearchClient({
366367
return createIterablePromise({
367368
...baseIteratorOptions,
368369
func: () =>
369-
this.getApiKey({ key }, requestOptions).catch((error) => error),
370-
validate: (error: ApiError) =>
371-
operation === 'add' ? error.status !== 404 : error.status === 404,
370+
this.getApiKey({ key }, requestOptions).catch((error: ApiError) => {
371+
if (error.status === 404) {
372+
return undefined;
373+
}
374+
375+
throw error;
376+
}),
377+
validate: (response) =>
378+
operation === 'add' ? response !== undefined : response === undefined,
372379
});
373380
},
374381

0 commit comments

Comments
 (0)