mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2024-12-23 20:09:23 +00:00
handle errors more reliably
This commit is contained in:
parent
ad5f9b3de4
commit
177eb70d51
1 changed files with 6 additions and 2 deletions
|
@ -188,8 +188,11 @@ class SimplexAPI {
|
||||||
}
|
}
|
||||||
final jsonArray = jsonDecode(res.body);
|
final jsonArray = jsonDecode(res.body);
|
||||||
if (jsonArray.containsKey('error') as bool) {
|
if (jsonArray.containsKey('error') as bool) {
|
||||||
|
if (jsonArray['error'] == true || jsonArray['error'] == 'true') {
|
||||||
|
// jsonArray['error'] as bool == true?
|
||||||
throw Exception('getQuote exception: ${jsonArray['error']}');
|
throw Exception('getQuote exception: ${jsonArray['error']}');
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
jsonArray['quote'] = quote; // Add and pass this on
|
jsonArray['quote'] = quote; // Add and pass this on
|
||||||
|
|
||||||
|
@ -273,10 +276,11 @@ class SimplexAPI {
|
||||||
throw Exception('newOrder exception: statusCode= ${res.statusCode}');
|
throw Exception('newOrder exception: statusCode= ${res.statusCode}');
|
||||||
}
|
}
|
||||||
final jsonArray = jsonDecode(res.body); // TODO check if valid json
|
final jsonArray = jsonDecode(res.body); // TODO check if valid json
|
||||||
|
if (jsonArray.containsKey('error') as bool) {
|
||||||
if (jsonArray['error'] == true || jsonArray['error'] == 'true') {
|
if (jsonArray['error'] == true || jsonArray['error'] == 'true') {
|
||||||
print('error');
|
|
||||||
throw Exception(jsonArray['message']);
|
throw Exception(jsonArray['message']);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
SimplexOrder _order = SimplexOrder(
|
SimplexOrder _order = SimplexOrder(
|
||||||
quote: quote,
|
quote: quote,
|
||||||
|
|
Loading…
Reference in a new issue