From c024770b4a5726d816d98d5a3d1acebb526ca109 Mon Sep 17 00:00:00 2001 From: Mathis Date: Mon, 29 Apr 2024 09:53:18 +0200 Subject: [PATCH] feat(services): handle MySQL connection errors with process exit Updated `mysql.service.ts` to handle MySQL connection errors by terminating the process instead of throwing a generic error. This change provides a more direct response to database connection failures. Signed-off-by: Mathis --- src/services/mysql.service.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/services/mysql.service.ts b/src/services/mysql.service.ts index 533f646..e976c9d 100644 --- a/src/services/mysql.service.ts +++ b/src/services/mysql.service.ts @@ -5,6 +5,7 @@ import type {IDbBrand} from "@interfaces/database/IDbBrand"; import type {IDbStatusResult} from "@interfaces/database/IDbStatusResult"; import mysql, {type Connection, type ConnectionOptions} from 'mysql2'; import {Logger} from "tslog"; +import process from "node:process"; const access: ConnectionOptions = { @@ -28,7 +29,7 @@ class MysqlHandler { this.Connection.connect((err) => { if (err) { this.Logger.error(`Error connecting to MySQL: ${err}`); - throw new Error() + process.exit(1); } this.Logger.info(`Connected to MySQL database (${access.database})`); });