File tree 2 files changed +17
-8
lines changed
templates/javascript/clients/client/api
2 files changed +17
-8
lines changed Original file line number Diff line number Diff line change @@ -31,3 +31,5 @@ method:
31
31
$ref : ' ../../common/responses/IndexInSameApp.yml'
32
32
' 403 ' :
33
33
$ref : ' ../../common/responses/IndexAlreadyExists.yml'
34
+ ' 404 ' :
35
+ $ref : ' ../../common/responses/IndexNotFound.yml'
Original file line number Diff line number Diff line change @@ -52,15 +52,22 @@ async accountCopyIndex(
52
52
): Promise<void > {
53
53
const responses: Array< { taskID: UpdatedAtResponse[' taskID' ] } > = [];
54
54
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
+ }
62
61
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' );
64
71
}
65
72
66
73
responses.push(
You can’t perform that action at this time.
0 commit comments