mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-12-22 19:49:22 +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)));
|
||||
if (response.statusCode == 400) {
|
||||
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) {
|
||||
|
|
|
@ -59,7 +59,7 @@ class ExceptionHandler {
|
|||
}
|
||||
|
||||
static void onError(FlutterErrorDetails errorDetails) {
|
||||
if (_isErrorFromUser(errorDetails.exception.toString())) {
|
||||
if (_ignoreError(errorDetails.exception.toString())) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -97,8 +97,9 @@ class ExceptionHandler {
|
|||
);
|
||||
}
|
||||
|
||||
/// User related errors to be added as exceptions here to not report
|
||||
static bool _isErrorFromUser(String error) {
|
||||
return error.contains("Software caused connection abort"); // User connection issue
|
||||
/// Ignore User related errors or system errors
|
||||
static bool _ignoreError(String error) {
|
||||
return error.contains("errno = 103") || // SocketException: Software caused connection abort
|
||||
error.contains("errno = 9"); // SocketException: Bad file descriptor (iOS socket exception)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue