Skip to content

Commit

Permalink
Add try-catch
Browse files Browse the repository at this point in the history
  • Loading branch information
slvrtrn committed Oct 15, 2024
1 parent 48098c1 commit 607ddad
Showing 1 changed file with 20 additions and 9 deletions.
29 changes: 20 additions & 9 deletions packages/client-common/__tests__/utils/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,15 +101,26 @@ export async function createRandomDatabase(
maybeOnCluster = ` ON CLUSTER '{cluster}'`
}
const ddl = `CREATE DATABASE IF NOT EXISTS ${databaseName}${maybeOnCluster}`
console.log(`\nCreating database ${databaseName} with DDL:\n${ddl}`)
await client.command({
query: ddl,
clickhouse_settings: {
wait_end_of_query: 1,
},
})
console.log(`\nCreated database ${databaseName}`)
return databaseName
const startTime = Date.now()
try {
console.log(`\nCreating database ${databaseName} with DDL:\n${ddl}`)
await client.command({
query: ddl,
clickhouse_settings: {
wait_end_of_query: 1,
},
})
console.log(
`\nCreated database ${databaseName} after ${Date.now() - startTime} ms`,
)
return databaseName
} catch (e) {
console.error(
`Failed to create database ${databaseName} after ${Date.now() - startTime} ms`,
e,
)
process.exit(1)
}
}

export async function createTable<Stream = unknown>(
Expand Down

0 comments on commit 607ddad

Please sign in to comment.