[flutter_tool] Where possible, catch only subtypes of Exception (#51440)

This commit is contained in:
Zachary Anderson
2020-02-26 21:45:02 -08:00
committed by GitHub
parent 80619f100f
commit f1cd47ef5c
84 changed files with 308 additions and 204 deletions

View File

@@ -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 {

View File

@@ -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');
}

View File

@@ -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');
}