better error handling

This commit is contained in:
julian 2023-04-11 16:09:18 -06:00
parent 68734132a1
commit b36c98f003

View file

@ -501,12 +501,19 @@ abstract class EthereumAPI {
if (response.statusCode == 200) { if (response.statusCode == 200) {
final json = jsonDecode(response.body) as Map; final json = jsonDecode(response.body) as Map;
if (json["success"] == true) { if (json["success"] == true) {
return EthereumResponse( try {
GasTracker.fromJson( return EthereumResponse(
Map<String, dynamic>.from(json["result"]["result"] as Map), GasTracker.fromJson(
), Map<String, dynamic>.from(json["result"]["result"] as Map),
null, ),
); null,
);
} catch (_) {
throw EthApiException(
"getGasOracle() failed with response: "
"${response.body}",
);
}
} else { } else {
throw EthApiException( throw EthApiException(
"getGasOracle() failed with response: " "getGasOracle() failed with response: "