From ee5e1801f055dda92221cd47733d95d76456343a Mon Sep 17 00:00:00 2001 From: alexandercerutti Date: Fri, 20 Jul 2018 15:11:41 +0200 Subject: [PATCH] Added error check inside pass.json reading block --- index.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index ccfa7ad..7a78038 100644 --- a/index.js +++ b/index.js @@ -113,7 +113,17 @@ class Pass { // Otherwise would had to put everything in editPassStructure's Promise .then(). async.parallel([ passCallback => { - fs.readFile(path.resolve(this.modelDirectory, `${this.modelName}.pass`, "pass.json"), {}, (err, passStructBuffer) => { + fs.readFile(path.resolve(computedModelPath, "pass.json"), {}, (err, passStructBuffer) => { + if (err) { + // Flow should never enter in there since pass.json existence-check is already done above. + return passCallback({ + status: false, + error: { + message: `Unable to read pass.json file @ ${computedModelPath}` + } + }); + } + if (!this._validateType(passStructBuffer)) { return passCallback({ status: false,