From 52953a1d0d48132e8bdb7a4bd0d00517265dc0e5 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Wed, 20 Dec 2017 14:54:47 -0500 Subject: [PATCH] warn about cycling dependencies --- lib/contracts/contracts.js | 11 ++++++++++- lib/contracts/deploy_manager.js | 1 + lib/core/test_logger.js | 1 + 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/contracts/contracts.js b/lib/contracts/contracts.js index 9940e8098..1a167be81 100644 --- a/lib/contracts/contracts.js +++ b/lib/contracts/contracts.js @@ -204,7 +204,16 @@ class ContractsManager { } } - let orderedDependencies = toposort(converted_dependencies).reverse(); + let orderedDependencies; + + try { + orderedDependencies = toposort(converted_dependencies).reverse(); + } catch(e) { + this.logger.error(("Error: " + e.message).red); + this.logger.error("there are two or more contracts that depend on each other in a cyclic manner".bold.red); + this.logger.error("Embark couldn't determine which one to deploy first".red); + process.exit(0); + } let newList = contractList.sort(function (a, b) { let order_a = orderedDependencies.indexOf(a.className); diff --git a/lib/contracts/deploy_manager.js b/lib/contracts/deploy_manager.js index 08bc20753..54860326a 100644 --- a/lib/contracts/deploy_manager.js +++ b/lib/contracts/deploy_manager.js @@ -55,6 +55,7 @@ class DeployManager { function setDefaultAccount(contractsManager, web3, callback) { web3.eth.getAccounts(function (err, accounts) { if (err) { + self.logger.error(err); return callback(new Error(err)); } let accountConfig = self.config.blockchainConfig.account; diff --git a/lib/core/test_logger.js b/lib/core/test_logger.js index e83c5e007..ce342eb69 100644 --- a/lib/core/test_logger.js +++ b/lib/core/test_logger.js @@ -25,6 +25,7 @@ class TestLogger { if (!(this.shouldLog('error'))) { return; } + console.error(txt); this.logFunction(txt.red); }