mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-06-28 20:39:51 +00:00
Merge pull request #760 from cake-tech/exception_handler_enhancements
Exception Handler Enhancements
This commit is contained in:
commit
a2cb99a331
2 changed files with 6 additions and 5 deletions
|
@ -80,7 +80,7 @@ class AnyPayApi {
|
||||||
final response = await post(Uri.parse(uri), headers: headers, body: utf8.encode(json.encode(body)));
|
final response = await post(Uri.parse(uri), headers: headers, body: utf8.encode(json.encode(body)));
|
||||||
if (response.statusCode == 400) {
|
if (response.statusCode == 400) {
|
||||||
final decodedBody = json.decode(response.body) as Map<String, dynamic>;
|
final decodedBody = json.decode(response.body) as Map<String, dynamic>;
|
||||||
throw Exception(decodedBody['message'] as String);
|
throw Exception(decodedBody['message'] as String? ?? 'Unexpected response\nError code: 400');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (response.statusCode != 200) {
|
if (response.statusCode != 200) {
|
||||||
|
|
|
@ -59,7 +59,7 @@ class ExceptionHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void onError(FlutterErrorDetails errorDetails) {
|
static void onError(FlutterErrorDetails errorDetails) {
|
||||||
if (_isErrorFromUser(errorDetails.exception.toString())) {
|
if (_ignoreError(errorDetails.exception.toString())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,8 +97,9 @@ class ExceptionHandler {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// User related errors to be added as exceptions here to not report
|
/// Ignore User related errors or system errors
|
||||||
static bool _isErrorFromUser(String error) {
|
static bool _ignoreError(String error) {
|
||||||
return error.contains("Software caused connection abort"); // User connection issue
|
return error.contains("errno = 103") || // SocketException: Software caused connection abort
|
||||||
|
error.contains("errno = 9"); // SocketException: Bad file descriptor (iOS socket exception)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue