Added error handling to header
This commit is contained in:
parent
e0764db85d
commit
d1b1784e4d
@ -92,7 +92,8 @@ class App extends Component {
|
||||
accounts={this.state.accounts}
|
||||
balance={this.state.balance}
|
||||
error={this.state.error}
|
||||
onAfterUserUpdate={(e) => this._loadCurrentUser()} />
|
||||
onAfterUserUpdate={(e) => this._loadCurrentUser()}
|
||||
onError={(err, source) => this._onError(err, source)} />
|
||||
<Main
|
||||
user={this.state.user}
|
||||
account={this.state.account}
|
||||
|
@ -75,7 +75,7 @@ class Header extends Component {
|
||||
*/
|
||||
_initUserAccounts = async () => {
|
||||
await map(this.props.accounts, async function (address, next) {
|
||||
|
||||
try {
|
||||
// gets the balance of the address
|
||||
const balance = await web3.eth.getBalance(address);
|
||||
|
||||
@ -94,7 +94,12 @@ class Header extends Component {
|
||||
user: user,
|
||||
balance: web3.utils.fromWei(balance, 'ether')
|
||||
});
|
||||
}
|
||||
catch (err) {
|
||||
next(err);
|
||||
}
|
||||
}, (err, userAccounts) => {
|
||||
if(err) return this.props.onError(err, 'Header._initUserAccounts');
|
||||
this.setState({ userAccounts: userAccounts })
|
||||
});
|
||||
}
|
||||
@ -274,7 +279,7 @@ class Header extends Component {
|
||||
</Dropdown.Menu>
|
||||
</Dropdown>
|
||||
</ButtonToolbar>
|
||||
{ isEditable ? states.tweet : '' }
|
||||
{isEditable ? states.tweet : ''}
|
||||
</React.Fragment>
|
||||
}
|
||||
</div>
|
||||
|
Loading…
x
Reference in New Issue
Block a user