fix: change connect db error handling

This commit is contained in:
wancat committed 2023-10-14 15:49:13 +08:00
1 parent d3dd12a547
commit cc9040038d
2 files changed
+7 -3

No files matched your search

+1 -2
View File
@@ -16,7 +16,6 @@ export default async function connectDB(uri) {
return db.connection.getClient()
} catch (err) {
console.error(err)
process.exit(1)
return null
throw new Error('Failed to connect to MongoDB')
}
}
+6 -1
View File
@@ -17,7 +17,12 @@ import expiryRemovalScheduler from './containers/expiryChecker.js'
import { createTestUser } from './utils/auth.js'
async function main() {
await connectDB(config.db)
try {
await connectDB(config.db)
} catch (err) {
console.error(err)
process.exit(1)
}
await createTestUser()