Skip to content

Commit

Permalink
Propagate errors to user
Browse files Browse the repository at this point in the history
  • Loading branch information
TimDaub committed Jul 1, 2019
1 parent 170e76b commit 681c464
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 21 deletions.
1 change: 1 addition & 0 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -828,6 +828,7 @@ export default class App extends Component {
title={i18n.t('offramp.history.title')}
goBack={this.goBack.bind(this)}/>
<BityHistory
changeAlert={this.changeAlert}
address={this.state.account}
orderId={orderId}
/>
Expand Down
36 changes: 15 additions & 21 deletions src/components/Bity.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,19 +95,19 @@ class Bity extends Component {
}

async componentDidMount() {
const { changeAlert } = this.props;

this.refs.name.focus();
await this.getMinAmount();
try {
await this.getMinAmount();
} catch (err) {
changeAlert("warning", i18n.t("offramping.errors.bity_connection"));
}
}

async getMinAmount() {
const { ethPrice } = this.props;
let estimate;
try {
estimate = await getEstimate("1");
} catch (err) {
// TODO: Propagate to user
console.log(err);
}
const estimate = await getEstimate("1");

MIN_AMOUNT_DOLLARS = Math.ceil(estimate.input.minimum_amount * ethPrice);
}
Expand All @@ -122,7 +122,8 @@ class Bity extends Component {
mainnetweb3,
web3,
changeView,
setReceipt
setReceipt,
changeAlert
} = this.props;
if (IBAN.valid) {
changeView("loader");
Expand All @@ -137,8 +138,7 @@ class Bity extends Component {
address
);
} catch (err) {
// TODO: Propagate to user
console.log(err);
changeAlert("warning", i18n.t("offramping.errors.bity_connection"));
return;
}

Expand All @@ -154,8 +154,7 @@ class Bity extends Component {
try {
gwei = await gasPrice();
} catch (err) {
// TODO: Propagate to user
console.log("Error getting gas price", err);
changeAlert("warning", i18n.t("offramping.errors.ethgasstation_connection"));
return;
}
const tx = {
Expand All @@ -171,14 +170,9 @@ class Bity extends Component {
metaAccount.privateKey
);

try {
receipt = await mainnetweb3.eth.sendSignedTransaction(
signed.rawTransaction
);
} catch (err) {
// TODO: Propagate to user
console.log(err);
}
receipt = await mainnetweb3.eth.sendSignedTransaction(
signed.rawTransaction
);
} else {
receipt = await web3.eth.sendTransaction({
from: address,
Expand Down
4 changes: 4 additions & 0 deletions src/i18n/locales/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,10 @@
"received": "Ether erhalten.",
"received": "Ether gegen EURO getauscht."
}
},
"errors": {
"bity_connection": "Es gab ein Problem damit eine Verbindung zu unserer Partnerbörse bity.com herzustellen. Bitte versuche es später nochmal.",
"ethgasstation_connection": "Es gab ein Problem damit die zuletzt aktuellen Gaspreise für das Ethereum Netzwerk zu bestimmen. Bitte versuche daher deine Transaktion zu einem späteren Zeitpunkt zu senden."
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions src/i18n/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,10 @@
"received": "Received your ether.",
"executed": "Swapped your ether for EURO."
}
},
"errors": {
"bity_connection": "There was a problem connecting to our exchange provider bity.com. Please try again later.",
"ethgasstation_connection": "There was a problem getting the latest gas prices. Please try sending your transaction later."
}
}
}
Expand Down

0 comments on commit 681c464

Please sign in to comment.