forked from firka/flutter
Don't log stack traces to console on build failures (#44966)
This commit is contained in:
@@ -226,8 +226,11 @@ class AotBuilder {
|
||||
status?.stop();
|
||||
if (!result.success) {
|
||||
for (ExceptionMeasurement measurement in result.exceptions.values) {
|
||||
printError(measurement.exception.toString());
|
||||
printError(measurement.stackTrace.toString());
|
||||
printError('Target ${measurement.target} failed: ${measurement.exception}',
|
||||
stackTrace: measurement.fatal
|
||||
? measurement.stackTrace
|
||||
: null,
|
||||
);
|
||||
}
|
||||
throwToolExit('Failed to build aot.');
|
||||
}
|
||||
|
||||
@@ -556,6 +556,8 @@ class _BuildInstance {
|
||||
}
|
||||
}
|
||||
} catch (exception, stackTrace) {
|
||||
// TODO(jonahwilliams): throw specific exception for expected errors to mark
|
||||
// as non-fatal. All others should be fatal.
|
||||
node.target.clearStamp(environment);
|
||||
passed = false;
|
||||
skipped = false;
|
||||
@@ -573,12 +575,15 @@ class _BuildInstance {
|
||||
|
||||
/// Helper class to collect exceptions.
|
||||
class ExceptionMeasurement {
|
||||
ExceptionMeasurement(this.target, this.exception, this.stackTrace);
|
||||
ExceptionMeasurement(this.target, this.exception, this.stackTrace, {this.fatal = false});
|
||||
|
||||
final String target;
|
||||
final dynamic exception;
|
||||
final StackTrace stackTrace;
|
||||
|
||||
/// Whether this exception was a fatal build system error.
|
||||
final bool fatal;
|
||||
|
||||
@override
|
||||
String toString() => 'target: $target\nexception:$exception\n$stackTrace';
|
||||
}
|
||||
|
||||
@@ -126,8 +126,11 @@ Future<void> buildWithAssemble({
|
||||
|
||||
if (!result.success) {
|
||||
for (ExceptionMeasurement measurement in result.exceptions.values) {
|
||||
printError(measurement.exception.toString());
|
||||
printError(measurement.stackTrace.toString());
|
||||
printError('Target ${measurement.target} failed: ${measurement.exception}',
|
||||
stackTrace: measurement.fatal
|
||||
? measurement.stackTrace
|
||||
: null,
|
||||
);
|
||||
}
|
||||
throwToolExit('Failed to build bundle.');
|
||||
}
|
||||
|
||||
@@ -155,8 +155,12 @@ class AssembleCommand extends FlutterCommand {
|
||||
resourcePoolSize: argResults['resource-pool-size'],
|
||||
));
|
||||
if (!result.success) {
|
||||
for (MapEntry<String, ExceptionMeasurement> data in result.exceptions.entries) {
|
||||
printError('Target ${data.key} failed: ${data.value.exception}', stackTrace: data.value.stackTrace);
|
||||
for (ExceptionMeasurement measurement in result.exceptions.values) {
|
||||
printError('Target ${measurement.target} failed: ${measurement.exception}',
|
||||
stackTrace: measurement.fatal
|
||||
? measurement.stackTrace
|
||||
: null,
|
||||
);
|
||||
}
|
||||
throwToolExit('build failed.');
|
||||
}
|
||||
|
||||
@@ -54,8 +54,11 @@ Future<void> buildWeb(
|
||||
));
|
||||
if (!result.success) {
|
||||
for (ExceptionMeasurement measurement in result.exceptions.values) {
|
||||
printError(measurement.stackTrace.toString());
|
||||
printError(measurement.exception.toString());
|
||||
printError('Target ${measurement.target} failed: ${measurement.exception}',
|
||||
stackTrace: measurement.fatal
|
||||
? measurement.stackTrace
|
||||
: null,
|
||||
);
|
||||
}
|
||||
throwToolExit('Failed to compile application for the Web.');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user