mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00
[flutter_tools] dont let crash reporter crash tool (#66755)
package:http can throw a ClientException, which the crash reporter must catch or the tool will crash in the crash reporter. 3/4 crash on dev.
This commit is contained in:
parent
0f90747bb3
commit
b6768ec7a6
@ -188,7 +188,7 @@ class CrashReportSender {
|
||||
// Catch all exceptions to print the message that makes clear that the
|
||||
// crash logger crashed.
|
||||
} catch (sendError, sendStackTrace) { // ignore: avoid_catches_without_on_clauses
|
||||
if (sendError is SocketException || sendError is HttpException) {
|
||||
if (sendError is SocketException || sendError is HttpException || sendError is http.ClientException) {
|
||||
_logger.printError('Failed to send crash report due to a network error: $sendError');
|
||||
} else {
|
||||
// If the sender itself crashes, just print. We did our best.
|
||||
|
@ -183,6 +183,25 @@ void main() {
|
||||
expect(logger.errorText, contains('Failed to send crash report due to a network error'));
|
||||
});
|
||||
|
||||
testWithoutContext('should print an explanatory message when there is a ClientException', () async {
|
||||
final CrashReportSender crashReportSender = CrashReportSender(
|
||||
client: CrashingCrashReportSender(const HttpException('no internets')),
|
||||
usage: mockUsage,
|
||||
platform: platform,
|
||||
logger: logger,
|
||||
operatingSystemUtils: operatingSystemUtils,
|
||||
);
|
||||
|
||||
await crashReportSender.sendReport(
|
||||
error: ClientException('Test bad state error'),
|
||||
stackTrace: null,
|
||||
getFlutterVersion: () => 'test-version',
|
||||
command: 'crash',
|
||||
);
|
||||
|
||||
expect(logger.errorText, contains('Failed to send crash report due to a network error'));
|
||||
});
|
||||
|
||||
testWithoutContext('should send only one crash report when sent many times', () async {
|
||||
final RequestInfo requestInfo = RequestInfo();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user