diff --git a/db/db.js b/db/db.js index e38e903..694a77b 100644 --- a/db/db.js +++ b/db/db.js @@ -12,14 +12,15 @@ const connectedToDb = async () => { return; } - try { - await mongoose.connect(MONGO_URI, { - dbName: "leadllyQuestions", - }); - console.log("Connected to db"); - } catch (error) { - console.error("mongo error =========>", error); - } +try { +await mongoose.connect(MONGO_URI, { +dbName: "leadllyQuestions", +}); +console.log("Connected to db"); +} catch (error) { +console.error("Database connection error:", error); +process.exit(1); // Exit the application if the database connection fails +} }; export default connectedToDb;