From 2356040572922cfbaa7384a43eb2b7a2ae17f809 Mon Sep 17 00:00:00 2001 From: Ruakij Date: Fri, 26 Nov 2021 19:07:27 +0100 Subject: [PATCH] Move catch into then-onRejected to fix resolving then anyways. --- src/helper/influx-checks.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/helper/influx-checks.js b/src/helper/influx-checks.js index 0d17c30..9475348 100644 --- a/src/helper/influx-checks.js +++ b/src/helper/influx-checks.js @@ -40,12 +40,7 @@ function checkWriteApi(influxDb, options){ const writeApi = influxDb.getWriteApi(options.org, options.bucket); // Get WriteAPI writeApi.writePoint(new Point("test").tag("ConnectionTest", true).intField("value", 0).timestamp(0)) // Write dummy-point writeApi.close() - .catch((err) => { - logger.error("Could not get writeApi:"); - logger.error(`Error [${err.code}]:`, err.message); - if(err.code == "not found") logger.error("No write-permission?"); - reject(); - }).then((res) => { + .then((res) => { logger.debug("Writing ok"); // Delete the connection-text-point @@ -64,6 +59,11 @@ function checkWriteApi(influxDb, options){ reject(); }) .then(resolve()) + }, + (err) => { + logger.error("Could not get writeApi:"); + logger.error(`Error [${err.code}]:`, err.message); + reject(); }); }); }