[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

@@ -211,7 +211,7 @@ class ChromeLauncher {
if (!skipCheck) {
try {
await chrome.chromeConnection.getTabs();
} catch (e) {
} on Exception catch (e) {
await chrome.close();
throwToolExit(
'Unable to connect to Chrome debug port: ${chrome.debugPort}\n $e');
@@ -235,7 +235,7 @@ class ChromeLauncher {
final HttpClientResponse response = await request.close();
final List<dynamic> jsonObject = await json.fuse(utf8).decoder.bind(response).single as List<dynamic>;
return base.resolve(jsonObject.first['devtoolsFrontendUrl'] as String);
} catch (_) {
} on Exception {
// If we fail to talk to the remote debugger protocol, give up and return
// the raw URL rather than crashing.
return base;

View File

@@ -66,7 +66,7 @@ Future<void> buildWeb(
}
throwToolExit('Failed to compile application for the Web.');
}
} catch (err) {
} on Exception catch (err) {
throwToolExit(err.toString());
} finally {
status.stop();