Simplified error handling

This commit is contained in:
Richard Ramos 2018-05-14 09:42:29 -04:00 committed by Pascal Precht
parent 152cf4c87b
commit 2d1d9994ad
No known key found for this signature in database
GPG Key ID: 0EE28D8D6FD85D7D
1 changed files with 5 additions and 14 deletions

View File

@ -1,7 +1,3 @@
const commandName = "generate-ui";
const errorMessage = (message) => new Error(commandName + ": " + message);
class Scaffolding { class Scaffolding {
constructor(embark, options){ constructor(embark, options){
this.embark = embark; this.embark = embark;
@ -30,21 +26,16 @@ class Scaffolding {
}); });
if(build === null){ if(build === null){
throw errorMessage("Could not find plugin for framework '" + this.framework + "'"); throw new Error("Could not find plugin for framework '" + this.framework + "'");
} }
if(!this.isContract(contractName)){ if(!this.isContract(contractName)){
return errorMessage("contract '" + contractName + "' does not exist"); return new Error("contract '" + contractName + "' does not exist");
} }
const contract = contractConfiguration.contracts[contractName]; const contract = contractConfiguration.contracts[contractName];
const result = build(contract);
try { this.embark.logger.info(result);
let result = build(contract);
this.embark.logger.info(result);
} catch(err){
throw errorMessage(err);
}
} }
} }