فهرست منبع

fix: handle errors without mis-calling R

jmacura 5 سال پیش
والد
کامیت
b401a314d2
2فایلهای تغییر یافته به همراه4 افزوده شده و 1 حذف شده
  1. 1 1
      index.js
  2. 3 0
      nuts-data.js

+ 1 - 1
index.js

@@ -184,7 +184,7 @@ app.post('/clusters', async (req, res, next) => {
         });
         handleRCall(req, res);
     } catch (error) { // Catch errors in async functions
-        next(error);
+        next(error.toString());
     }
 });
 

+ 3 - 0
nuts-data.js

@@ -137,6 +137,9 @@ module.exports.modifyClusteringData = async function ({datasets, data, params, o
         }).filter(val => val !== null);
     });
     //console.log(modifiedData);
+    if (modifiedData[0].length <= 1) {
+        throw new Error('All datasets turned off. No data to create clusters.');
+    }
     return new Promise((resolve, reject) => {
         stringify(modifiedData, (err, output) => {
             if (err) return reject(err);