Skip to content

Commit 7ac7247

Browse files
authored
Merge pull request #56 from gregholland/master
fix: don’t throw an error if index already exists
2 parents f02265e + 118a145 commit 7ac7247

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/index.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,11 @@ export async function start(options: StartESOptions): Promise<void> {
8989
const error = getESError(result);
9090

9191
if (error) {
92-
throw new Error(`Failed to create index: ${error.reason}`);
92+
if (error.type === 'resource_already_exists_exception') {
93+
debug(`Index ${name} already exists.`);
94+
} else {
95+
throw new Error(`Failed to create index: ${error.reason}`);
96+
}
9397
}
9498
})
9599
);
@@ -139,6 +143,7 @@ async function isExistingFile(filepath: string): Promise<boolean> {
139143

140144
interface ESError {
141145
reason: string;
146+
type: string;
142147
}
143148

144149
function getESError(esResponse: Buffer): ESError | undefined {

0 commit comments

Comments
 (0)