CWA-169 | added try-catch to calculateAmount() in MorphTokenExchangeProvider

Oleksandr Sobol committed Feb 7, 2020 at 15:34 UTC eb875b1321c604dc6bd782fed1a827fa8d47aa53
1 file changed +6 -2
lib/src/domain/exchange/morphtoken/morphtoken_exchange_provider.dart
+6 -2
@@ -214,8 +214,12 @@ class MorphTokenExchangeProvider extends ExchangeProvider {
214 final response = await get(url);
215 final responseJSON = json.decode(response.body) as Map<String, dynamic>;
216 final rate = responseJSON['data'][from.toString()][to.toString()] as String;
217 - final estimatedAmount = double.parse(rate) * amount;
217
219 - return estimatedAmount;
218 + try {
219 + final estimatedAmount = double.parse(rate) * amount;
220 + return estimatedAmount;
221 + } catch(e) {
222 + return 0.0;
223 + }
224 }
225 }