Skip to content

Commit

Permalink
Handle multiple errors
Browse files Browse the repository at this point in the history
Signed-off-by: Stefan Marr <[email protected]>
  • Loading branch information
smarr committed Jan 20, 2024
1 parent 854713c commit ec5681e
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,10 +172,20 @@ app.use(router.allowedMethods());
await db.initializeDatabase();
} catch (e: any) {
if (e.code == 'ECONNREFUSED') {
log.error(
`Unable to connect to database on port ${e.address}:${e.port}\n` +
'ReBenchDB requires a Postgres database to work.'
);
if (e.errors && e.errors.length > 0) {
const e2 = e.errors[0];
log.error(
`Unable to connect to database on port ${e2.address}:${e2.port}.\n` +
'Connection refused.\n' +
'ReBenchDB requires a Postgres database to work.'
);
} else {
log.error(
`Unable to connect to database on port ${e.address}:${e.port}.\n` +
'Connection refused.\n' +
'ReBenchDB requires a Postgres database to work.'
);
}
process.exit(1);
}
}
Expand Down

0 comments on commit ec5681e

Please sign in to comment.