From 2d66e14f15500f016d7d5e01eca89eae008aa6a9 Mon Sep 17 00:00:00 2001 From: alexandercerutti Date: Tue, 24 Jul 2018 00:57:21 +0200 Subject: [PATCH] Changed schema violation from throw to Promise rejection --- index.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index f2944b8..331fcec 100644 --- a/index.js +++ b/index.js @@ -394,10 +394,16 @@ class Pass { */ _parseSettings(options) { + if (!schema.isValid(options, schema.constants.instance)) { + return Promise.reject({ + status: false, + error: { + message: "The options passed to Pass constructor does not meet the requirements. Refer to the documentation to compile them correctly." + } + }); + } + return new Promise((success, reject) => { - if (!schema.isValid(options, schema.constants.instance)) { - throw new Error("The options passed to Pass constructor does not meet the requirements. Refer to the documentation to compile them correctly."); - } if (!options.model || typeof options.model !== "string") { return reject({