From d7b6820aa27039e9496b578786f0ff9ec9b3d6fe Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Sat, 18 Feb 2023 18:20:29 +0800 Subject: [PATCH] feat(nocodb): add ncUpgradeError --- .../lib/version-upgrader/ncUpgradeErrors.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 packages/nocodb/src/lib/version-upgrader/ncUpgradeErrors.ts diff --git a/packages/nocodb/src/lib/version-upgrader/ncUpgradeErrors.ts b/packages/nocodb/src/lib/version-upgrader/ncUpgradeErrors.ts new file mode 100644 index 0000000000..dd278404c1 --- /dev/null +++ b/packages/nocodb/src/lib/version-upgrader/ncUpgradeErrors.ts @@ -0,0 +1,19 @@ +export function throwTimeoutError(e, timeoutErrorInfo) { + if (e.code === 'ETIMEDOUT') { + let db = ''; + if (timeoutErrorInfo.connection.filename) { + // for sqlite + db = timeoutErrorInfo.connection.filename; + } else if ( + timeoutErrorInfo.connection.database && + timeoutErrorInfo.connection.host && + timeoutErrorInfo.connection.port + ) { + db = `${timeoutErrorInfo.connection.database} (${timeoutErrorInfo.connection.host}:${timeoutErrorInfo.connection.port})`; + } + throw new Error( + `Failed to connect the database ${db} for Project ${timeoutErrorInfo.projectTitle}. + Please fix the connection issue or remove the project before trying to upgrade.` + ); + } +}