From 69f1ec07d68721ac76da091890dfd2812ef6334c Mon Sep 17 00:00:00 2001 From: Noel Pascal Schwabenland Date: Mon, 29 Jan 2024 19:06:11 +0100 Subject: [PATCH] added more error handling --- src/storage.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/storage.ts b/src/storage.ts index 2691768..d762c3a 100644 --- a/src/storage.ts +++ b/src/storage.ts @@ -9,8 +9,9 @@ import { MysqlError, Pool } from 'mysql'; * @param callback Callback function * @param pool Pool to use */ -export function query(query: string, inputs: any[], callback: (error: MysqlError, result: any[]) => void, pool: Pool) { +export function query(query: string, inputs: any[], callback: (error: MysqlError, result: any[]) => void, pool: Pool) : void { pool.getConnection(function (error, connection) { + if (error) callback(error, []); connection.beginTransaction(function (error) { if (error) { // Transaction Error (Rollback and release connection)