diff --git a/src/utils/connectToDB.ts b/src/utils/connectToDB.ts index 0d1f357..39c2c71 100644 --- a/src/utils/connectToDB.ts +++ b/src/utils/connectToDB.ts @@ -1,5 +1,7 @@ import mongoose from 'mongoose' +import { InternalServerError } from './exceptions' + let cachedDbConnection: typeof mongoose | null = null export async function connectToDatabase(): Promise { @@ -17,6 +19,6 @@ export async function connectToDatabase(): Promise { return cachedDbConnection } catch (error: any) { cachedDbConnection = null - throw new Error(`Failed to connect to MongoDB: ${error.message}`) + throw new InternalServerError(`Failed to connect to MongoDB: ${error.message}`) } }