Skip to content
This repository has been archived by the owner on Jul 11, 2019. It is now read-only.

Commit

Permalink
Improve error handling in check methods of network base controller
Browse files Browse the repository at this point in the history
  • Loading branch information
spalladino committed Jul 23, 2018
1 parent 6668036 commit 7f51b2a
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/models/network/NetworkBaseController.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ export default class NetworkBaseController {
}

checkLocalContractsDeployed(throwIfFail = false) {
this._handleErrorMessage(this._errorForLocalContractsDeployed(), throwIfFail);
const err = this._errorForLocalContractsDeployed();
if (err) this._handleErrorMessage(err, throwIfFail);
}

_errorForLocalContractsDeployed() {
Expand All @@ -126,7 +127,8 @@ export default class NetworkBaseController {
}

checkLocalContractDeployed(contractAlias, throwIfFail = false) {
this._handleErrorMessage(this._errorForLocalContractDeployed(contractAlias), throwIfFail);
const err = this._errorForLocalContractDeployed(contractAlias);
if (err) this._handleErrorMessage(err, throwIfFail);
}

_errorForLocalContractDeployed(contractAlias) {
Expand All @@ -140,8 +142,11 @@ export default class NetworkBaseController {
}

_handleErrorMessage(msg, throwIfFail = false) {
if (msg && throwIfFail) throw Error(msg);
else if (msg) log.info(msg);
if (throwIfFail) {
throw Error(msg);
} else {
log.info(msg);
}
}

hasContractChanged(contractAlias) {
Expand Down

0 comments on commit 7f51b2a

Please sign in to comment.