Skip to content

Commit 00dd8ec

Browse files
committed
display compilation and/or deployment error in the logs and status instead of crashing
1 parent 816e673 commit 00dd8ec

File tree

1 file changed

+26
-8
lines changed

1 file changed

+26
-8
lines changed

lib/index.js

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ var Embark = {
5555
},
5656
self.buildDeployGenerate.bind(self)
5757
], function(err, result) {
58-
Embark.monitor.setStatus("Ready");
5958
self.logger.trace("finished".underline);
6059
});
6160
},
@@ -108,7 +107,7 @@ var Embark = {
108107
callback();
109108
}
110109
], function(err, result) {
111-
Embark.monitor.setStatus("Ready");
110+
Embark.monitor.setStatus("Ready".green);
112111
self.logger.trace("finished".underline);
113112
});
114113
},
@@ -144,8 +143,12 @@ var Embark = {
144143
contractsConfig: self.config.contractsConfig,
145144
logger: Embark.logger
146145
});
147-
contractsManager.build();
148-
callback(null, contractsManager);
146+
try {
147+
contractsManager.build();
148+
callback(null, contractsManager);
149+
} catch(err) {
150+
callback(new Error(err.message));
151+
}
149152
},
150153
function deployContracts(contractsManager, callback) {
151154

@@ -179,7 +182,11 @@ var Embark = {
179182

180183
}
181184
], function(err, result) {
182-
done(result);
185+
if (err) {
186+
done(err, null);
187+
} else {
188+
done(null, result);
189+
}
183190
});
184191
},
185192

@@ -204,11 +211,15 @@ var Embark = {
204211
buildDeployGenerate: function(done) {
205212
var self = this;
206213

214+
Embark.monitor.setStatus("Deploying...".magenta.underline);
207215
async.waterfall([
208216
function deployAndBuildContractsManager(callback) {
209-
Embark.monitor.setStatus("Deploying Contracts");
210-
Embark.buildAndDeploy(function(contractsManager) {
211-
callback(null, contractsManager);
217+
Embark.buildAndDeploy(function(err, contractsManager) {
218+
if (err) {
219+
callback(err);
220+
} else {
221+
callback(null, contractsManager);
222+
}
212223
});
213224
},
214225
function generateConsoleABI(contractsManager, callback) {
@@ -233,6 +244,13 @@ var Embark = {
233244
callback();
234245
}
235246
], function(err, result) {
247+
if (err) {
248+
self.logger.error("error deploying");
249+
self.logger.error(err.message);
250+
Embark.monitor.setStatus("Deployment Error".red);
251+
} else {
252+
Embark.monitor.setStatus("Ready".green);
253+
}
236254
done(result);
237255
});
238256
},

0 commit comments

Comments
 (0)