Skip to content

Commit

Permalink
fix(migrate): filter error log for create / can connect commands (#8657)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jolg42 committed Aug 9, 2021
1 parent d43bfb3 commit 295177d
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions packages/sdk/src/migrateEngineCommands.ts
Expand Up @@ -112,7 +112,10 @@ export async function canConnectToDatabase(
} catch (e) {
if (e.stderr) {
const logs = parseJsonFromStderr(e.stderr)
const error = logs.find((it) => it.level === 'ERROR')
const error = logs.find(
(it) =>
it.level === 'ERROR' && it.target === 'migration_engine::logger',
)

if (error && error.fields.error_code && error.fields.message) {
return {
Expand Down Expand Up @@ -162,7 +165,10 @@ export async function createDatabase(
} catch (e) {
if (e.stderr) {
const logs = parseJsonFromStderr(e.stderr)
const error = logs.find((it) => it.level === 'ERROR')
const error = logs.find(
(it) =>
it.level === 'ERROR' && it.target === 'migration_engine::logger',
)

if (error && error.fields.error_code && error.fields.message) {
throw new Error(`${error.fields.error_code}: ${error.fields.message}`)
Expand Down

0 comments on commit 295177d

Please sign in to comment.