From eb875b1321c604dc6bd782fed1a827fa8d47aa53 Mon Sep 17 00:00:00 2001 From: Oleksandr Sobol Date: Fri, 7 Feb 2020 15:34:00 +0200 Subject: [PATCH] CWA-169 | added try-catch to calculateAmount() in MorphTokenExchangeProvider --- .../exchange/morphtoken/morphtoken_exchange_provider.dart | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/src/domain/exchange/morphtoken/morphtoken_exchange_provider.dart b/lib/src/domain/exchange/morphtoken/morphtoken_exchange_provider.dart index b609d18ec..55df4d26e 100644 --- a/lib/src/domain/exchange/morphtoken/morphtoken_exchange_provider.dart +++ b/lib/src/domain/exchange/morphtoken/morphtoken_exchange_provider.dart @@ -214,8 +214,12 @@ class MorphTokenExchangeProvider extends ExchangeProvider { final response = await get(url); final responseJSON = json.decode(response.body) as Map; final rate = responseJSON['data'][from.toString()][to.toString()] as String; - final estimatedAmount = double.parse(rate) * amount; - return estimatedAmount; + try { + final estimatedAmount = double.parse(rate) * amount; + return estimatedAmount; + } catch(e) { + return 0.0; + } } }