[flutter_tool] Where possible, catch only subtypes of Exception (#51440)
This commit is contained in:
@@ -126,7 +126,9 @@ class CrashReportSender {
|
||||
} else {
|
||||
globals.printError('Failed to send crash report. Server responded with HTTP status code ${resp.statusCode}');
|
||||
}
|
||||
} catch (sendError, sendStackTrace) {
|
||||
// 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) {
|
||||
globals.printError('Failed to send crash report due to a network error: $sendError');
|
||||
} else {
|
||||
|
||||
@@ -195,7 +195,7 @@ class CommandResultEvent extends UsageEvent {
|
||||
label: parameter,
|
||||
value: maxRss,
|
||||
);
|
||||
} catch (error) {
|
||||
} on Exception catch (error) {
|
||||
// If grabbing the maxRss fails for some reason, just don't send an event.
|
||||
globals.printTrace('Querying maxRss failed with error: $error');
|
||||
}
|
||||
|
||||
@@ -136,7 +136,7 @@ ${_projectMetadataInformation()}
|
||||
} else {
|
||||
globals.printTrace('Failed to shorten GitHub template URL. Server responded with HTTP status code ${response.statusCode}');
|
||||
}
|
||||
} catch (sendError) {
|
||||
} on Exception catch (sendError) {
|
||||
globals.printTrace('Failed to shorten GitHub template URL: $sendError');
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user