V4.6.1 report fixes (#859)

* Add exception handler to anypay api response failure

* Check if context is still mounted before fetching iPad position

* Add user connection issue to ignored errors

* Wrap launchURL in empty try catch to avoid package un-needed exceptions
This commit is contained in:
Omar Hatem 2023-03-31 21:14:22 +02:00 committed by GitHub
parent 72df78ad8c
commit 37ef63d09e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 39 additions and 16 deletions

View file

@ -1,5 +1,6 @@
import 'dart:convert'; import 'dart:convert';
import 'package:cake_wallet/anypay/any_pay_payment_committed_info.dart'; import 'package:cake_wallet/anypay/any_pay_payment_committed_info.dart';
import 'package:cake_wallet/utils/exception_handler.dart';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:http/http.dart'; import 'package:http/http.dart';
import 'package:cw_core/crypto_currency.dart'; import 'package:cw_core/crypto_currency.dart';
@ -55,6 +56,7 @@ class AnyPayApi {
final response = await post(url, headers: headers, body: utf8.encode(json.encode(body))); final response = await post(url, headers: headers, body: utf8.encode(json.encode(body)));
if (response.statusCode != 200) { if (response.statusCode != 200) {
ExceptionHandler.onError(FlutterErrorDetails(exception: response));
throw Exception('Unexpected response http code: ${response.statusCode}'); throw Exception('Unexpected response http code: ${response.statusCode}');
} }

View file

@ -136,9 +136,11 @@ class ExceptionHandler {
"errno = 54", // SocketException: Connection reset by peer "errno = 54", // SocketException: Connection reset by peer
"errno = 57", // SocketException: Read failed (OS Error: Socket is not connected) "errno = 57", // SocketException: Read failed (OS Error: Socket is not connected)
"errno = 60", // SocketException: Operation timed out "errno = 60", // SocketException: Operation timed out
"errno = 65", // SocketException: No route to host
"errno = 103", // SocketException: Software caused connection abort "errno = 103", // SocketException: Software caused connection abort
"errno = 104", // SocketException: Connection reset by peer "errno = 104", // SocketException: Connection reset by peer
"errno = 110", // SocketException: Connection timed out "errno = 110", // SocketException: Connection timed out
"HttpException: Connection reset by peer",
"HttpException: Connection closed before full header was received", "HttpException: Connection closed before full header was received",
"HandshakeException: Connection terminated during handshake", "HandshakeException: Connection terminated during handshake",
"PERMISSION_NOT_GRANTED", "PERMISSION_NOT_GRANTED",

View file

@ -28,7 +28,11 @@ class ShareUtil {
); );
} }
static Rect? _sharePosition(BuildContext context) { static Rect _sharePosition(BuildContext context) {
if (!context.mounted) {
return Rect.zero;
}
final box = context.findRenderObject() as RenderBox?; final box = context.findRenderObject() as RenderBox?;
return box!.localToGlobal(Offset.zero) & box.size; return box!.localToGlobal(Offset.zero) & box.size;

View file

@ -81,21 +81,23 @@ abstract class OrderDetailsViewModelBase with Store {
: S.current.trade_details_fetching), : S.current.trade_details_fetching),
]); ]);
if (order.provider != null) { items.add(
items.add( StandartListItem(
StandartListItem( title: 'Buy provider',
title: 'Buy provider', value: order.provider.title)
value: order.provider.title) );
);
}
if (_provider!.trackUrl?.isNotEmpty ?? false) { if (_provider?.trackUrl.isNotEmpty ?? false) {
final buildURL = _provider!.trackUrl + '${order.transferId}'; final buildURL = _provider!.trackUrl + '${order.transferId}';
items.add( items.add(
TrackTradeListItem( TrackTradeListItem(
title: 'Track', title: 'Track',
value: buildURL, value: buildURL,
onTap: () => launch(buildURL) onTap: () {
try {
launch(buildURL);
} catch (e) {}
}
) )
); );
} }

View file

@ -21,6 +21,7 @@ import 'package:cake_wallet/src/screens/trade_details/track_trade_list_item.dart
import 'package:cake_wallet/src/screens/trade_details/trade_details_list_card.dart'; import 'package:cake_wallet/src/screens/trade_details/trade_details_list_card.dart';
import 'package:cake_wallet/src/screens/trade_details/trade_details_status_item.dart'; import 'package:cake_wallet/src/screens/trade_details/trade_details_status_item.dart';
import 'package:url_launcher/url_launcher.dart'; import 'package:url_launcher/url_launcher.dart';
part 'trade_details_view_model.g.dart'; part 'trade_details_view_model.g.dart';
class TradeDetailsViewModel = TradeDetailsViewModelBase with _$TradeDetailsViewModel; class TradeDetailsViewModel = TradeDetailsViewModelBase with _$TradeDetailsViewModel;
@ -121,23 +122,26 @@ abstract class TradeDetailsViewModelBase with Store {
title: 'Track', title: 'Track',
value: buildURL, value: buildURL,
onTap: () { onTap: () {
launch(buildURL); _launchUrl(buildURL);
})); }));
} }
if (trade.provider == ExchangeProviderDescription.sideShift) { if (trade.provider == ExchangeProviderDescription.sideShift) {
final buildURL = 'https://sideshift.ai/orders/${trade.id.toString()}'; final buildURL = 'https://sideshift.ai/orders/${trade.id.toString()}';
items.add(TrackTradeListItem(title: 'Track', value: buildURL, onTap: () => launch(buildURL))); items.add(
TrackTradeListItem(title: 'Track', value: buildURL, onTap: () => _launchUrl(buildURL)));
} }
if (trade.provider == ExchangeProviderDescription.simpleSwap) { if (trade.provider == ExchangeProviderDescription.simpleSwap) {
final buildURL = 'https://simpleswap.io/exchange?id=${trade.id.toString()}'; final buildURL = 'https://simpleswap.io/exchange?id=${trade.id.toString()}';
items.add(TrackTradeListItem(title: 'Track', value: buildURL, onTap: () => launch(buildURL))); items.add(
TrackTradeListItem(title: 'Track', value: buildURL, onTap: () => _launchUrl(buildURL)));
} }
if (trade.provider == ExchangeProviderDescription.trocador) { if (trade.provider == ExchangeProviderDescription.trocador) {
final buildURL = 'https://trocador.app/en/checkout/${trade.id.toString()}'; final buildURL = 'https://trocador.app/en/checkout/${trade.id.toString()}';
items.add(TrackTradeListItem(title: 'Track', value: buildURL, onTap: () => launch(buildURL))); items.add(
TrackTradeListItem(title: 'Track', value: buildURL, onTap: () => _launchUrl(buildURL)));
items.add(StandartListItem( items.add(StandartListItem(
title: '${trade.providerName} ${S.current.id.toUpperCase()}', title: '${trade.providerName} ${S.current.id.toUpperCase()}',
@ -148,4 +152,10 @@ abstract class TradeDetailsViewModelBase with Store {
title: '${trade.providerName} ${S.current.password}', value: trade.password ?? '')); title: '${trade.providerName} ${S.current.password}', value: trade.password ?? ''));
} }
} }
void _launchUrl(String url) {
try {
launch(url);
} catch (e) {}
}
} }

View file

@ -14,7 +14,6 @@ import 'package:cake_wallet/store/settings_store.dart';
import 'package:cake_wallet/generated/i18n.dart'; import 'package:cake_wallet/generated/i18n.dart';
import 'package:url_launcher/url_launcher.dart'; import 'package:url_launcher/url_launcher.dart';
import 'package:cake_wallet/monero/monero.dart'; import 'package:cake_wallet/monero/monero.dart';
import 'package:cake_wallet/haven/haven.dart';
part 'transaction_details_view_model.g.dart'; part 'transaction_details_view_model.g.dart';
@ -150,7 +149,11 @@ abstract class TransactionDetailsViewModelBase with Store {
items.add(BlockExplorerListItem( items.add(BlockExplorerListItem(
title: S.current.view_in_block_explorer, title: S.current.view_in_block_explorer,
value: _explorerDescription(type), value: _explorerDescription(type),
onTap: () => launch(_explorerUrl(type, tx.id)))); onTap: () {
try {
launch(_explorerUrl(type, tx.id));
} catch (e) {}
}));
final description = transactionDescriptionBox.values.firstWhere( final description = transactionDescriptionBox.values.firstWhere(
(val) => val.id == transactionInfo.id, (val) => val.id == transactionInfo.id,