mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-10-17 05:41:29 +02:00
fix: improve error handling and messaging in DFX Buy and OpenCryptoPay services (#2509)
* fix: improve error handling and messaging in DFX Buy and OpenCryptoPay services * fix: adjust error handling in DFX Buy provider by updating `_getErrorMessage` function parameters and removing unused imports
This commit is contained in:
@@ -4,8 +4,7 @@ class OpenCryptoPayException implements Exception {
|
||||
OpenCryptoPayException([this.message = '']);
|
||||
|
||||
@override
|
||||
String toString() =>
|
||||
'OpenCryptoPayException${message.isNotEmpty ? ': $message' : ''}';
|
||||
String toString() => message.isNotEmpty ? message : 'OpenCryptoPayException';
|
||||
}
|
||||
|
||||
class OpenCryptoPayNotSupportedException extends OpenCryptoPayException {
|
||||
|
||||
@@ -35,14 +35,12 @@ class OpenCryptoPayService {
|
||||
final response =
|
||||
await ProxyWrapper().get(clearnetUri: Uri.https(uri.authority, uri.path, queryParams));
|
||||
|
||||
final body = jsonDecode(response.body) as Map;
|
||||
if (response.statusCode == 200) {
|
||||
final body = jsonDecode(response.body) as Map;
|
||||
|
||||
if (body.keys.contains("txId")) return body["txId"] as String;
|
||||
throw OpenCryptoPayException(body.toString());
|
||||
}
|
||||
throw OpenCryptoPayException(
|
||||
"Unexpected status code ${response.statusCode} ${response.body}");
|
||||
throw OpenCryptoPayException("${response.statusCode}: ${body["message"]}");
|
||||
}
|
||||
|
||||
Future<void> cancelOpenCryptoPayRequest(OpenCryptoPayRequest request) async {
|
||||
|
||||
Reference in New Issue
Block a user