2
0
mirror of synced 2025-02-23 04:18:24 +00:00

Added error handling to header

This commit is contained in:
emizzle 2018-07-17 22:30:47 +02:00
parent e0764db85d
commit d1b1784e4d
2 changed files with 24 additions and 18 deletions

View File

@ -92,7 +92,8 @@ class App extends Component {
accounts={this.state.accounts} accounts={this.state.accounts}
balance={this.state.balance} balance={this.state.balance}
error={this.state.error} error={this.state.error}
onAfterUserUpdate={(e) => this._loadCurrentUser()} /> onAfterUserUpdate={(e) => this._loadCurrentUser()}
onError={(err, source) => this._onError(err, source)} />
<Main <Main
user={this.state.user} user={this.state.user}
account={this.state.account} account={this.state.account}

View File

@ -75,7 +75,7 @@ class Header extends Component {
*/ */
_initUserAccounts = async () => { _initUserAccounts = async () => {
await map(this.props.accounts, async function (address, next) { await map(this.props.accounts, async function (address, next) {
try {
// gets the balance of the address // gets the balance of the address
const balance = await web3.eth.getBalance(address); const balance = await web3.eth.getBalance(address);
@ -94,7 +94,12 @@ class Header extends Component {
user: user, user: user,
balance: web3.utils.fromWei(balance, 'ether') balance: web3.utils.fromWei(balance, 'ether')
}); });
}
catch (err) {
next(err);
}
}, (err, userAccounts) => { }, (err, userAccounts) => {
if(err) return this.props.onError(err, 'Header._initUserAccounts');
this.setState({ userAccounts: userAccounts }) this.setState({ userAccounts: userAccounts })
}); });
} }
@ -274,7 +279,7 @@ class Header extends Component {
</Dropdown.Menu> </Dropdown.Menu>
</Dropdown> </Dropdown>
</ButtonToolbar> </ButtonToolbar>
{ isEditable ? states.tweet : '' } {isEditable ? states.tweet : ''}
</React.Fragment> </React.Fragment>
} }
</div> </div>