Skip to content

Commit dec43f7

Browse files
committed
chore: errors
1 parent 22f8f13 commit dec43f7

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

specs/search/helpers/accountCopyIndex.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,5 @@ method:
3131
$ref: '../../common/responses/IndexInSameApp.yml'
3232
'403':
3333
$ref: '../../common/responses/IndexAlreadyExists.yml'
34+
'404':
35+
$ref: '../../common/responses/IndexNotFound.yml'

templates/javascript/clients/client/api/nodeHelpers.mustache

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,22 @@ async accountCopyIndex(
5252
): Promise<void> {
5353
const responses: Array<{ taskID: UpdatedAtResponse['taskID'] }> = [];
5454

55-
if (await destinationClient.indexExists({ indexName: sourceIndexName })) {
56-
if (this.appId === destinationClient.appId) {
57-
throw new AlgoliaError(
58-
'Indices are in the same application. Use operationIndex instead.',
59-
'IndexInSameApp',
60-
);
61-
}
55+
if (this.appId === destinationClient.appId) {
56+
throw new AlgoliaError(
57+
'Indices are in the same application. Use operationIndex instead.',
58+
'IndicesInTheSameAppError',
59+
);
60+
}
6261

63-
throw new AlgoliaError('Destination index already exists.', 'IndexAlreadyExists');
62+
if (!(await this.indexExists({ indexName: sourceIndexName }))) {
63+
throw new AlgoliaError(
64+
`${sourceIndexName} does not exist in the source application ${this.appId}`,
65+
'IndexNotFound',
66+
);
67+
}
68+
69+
if (await destinationClient.indexExists({ indexName: sourceIndexName })) {
70+
throw new AlgoliaError('Destination indice already exists.', 'DestinationIndiceAlreadyExistsError');
6471
}
6572

6673
responses.push(

0 commit comments

Comments
 (0)