From 808a07d218b724cb7fcf75b674190858677c2978 Mon Sep 17 00:00:00 2001 From: Kevin Jahns <kevin.jahns@rwth-aachen.de> Date: Wed, 24 Feb 2016 11:40:19 +0100 Subject: [PATCH] added some error messages --- src/y.js | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/y.js b/src/y.js index f62d9979..67a5400f 100644 --- a/src/y.js +++ b/src/y.js @@ -92,13 +92,21 @@ function Y (opts/* :YOptions */) /* :Promise<YConfig> */ { } Y.sourceDir = opts.sourceDir return Y.requestModules(modules).then(function () { - return new Promise(function (resolve) { - var yconfig = new YConfig(opts) - yconfig.db.whenUserIdSet(function () { - yconfig.init(function () { - resolve(yconfig) + return new Promise(function (resolve, reject) { + if (opts == null) reject('An options object is expected! ') + else if (opts.connector == null) reject('You must specify a connector! (missing connector property)') + else if (opts.connector.name == null) reject('You must specify connector name! (missing connector.name property)') + else if (opts.db == null) reject('You must specify a database! (missing db property)') + else if (opts.connector.name == null) reject('You must specify db name! (missing db.name property)') + else if (opts.share == null) reject('You must specify a set of shared types!') + else { + var yconfig = new YConfig(opts) + yconfig.db.whenUserIdSet(function () { + yconfig.init(function () { + resolve(yconfig) + }) }) - }) + } }) }) } -- GitLab