From dfe1694654d3d68b894c59e941e034e9a68d8760 Mon Sep 17 00:00:00 2001 From: gkoberger Date: Thu, 4 Jun 2020 16:07:51 -0700 Subject: [PATCH] Fix uncaught error on invalid JSON/YAML --- src/loader.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/loader.js b/src/loader.js index 494e391..6e08f87 100644 --- a/src/loader.js +++ b/src/loader.js @@ -87,20 +87,20 @@ class Loader { } static loadBase(base = '', options) { - return new Promise(resolve => { + return new Promise((resolve, reject) => { fs.stat(base, (err, stat) => { if (!err && stat.isFile()) { this.loadData(base, options).then(baseData => { resolve(baseData); - }); + }).catch(reject); } else if (!err && stat.isDirectory()) { this.findSwagger(base, options).then(baseData => { resolve(baseData); - }); + }).catch(reject); } else { this.findSwagger(process.cwd(), options).then(baseData => { resolve(baseData); - }); + }).catch(reject); } }); });