@@ -11,6 +11,10 @@ import 'package:meta/meta.dart';
1111import 'package:path/path.dart' as path;
1212import 'package:process/process.dart' ;
1313
14+ import 'src/errors.dart' ;
15+
16+ export 'src/errors.dart' show SkiaGoldProcessError;
17+
1418const String _kGoldctlKey = 'GOLDCTL' ;
1519const String _kPresubmitEnvName = 'GOLD_TRYJOB' ;
1620const String _kLuciEnvName = 'LUCI_CONTEXT' ;
@@ -154,11 +158,13 @@ interface class SkiaGoldClient {
154158 ..writeln ('Skia Gold authorization failed.' )
155159 ..writeln ('Luci environments authenticate using the file provided '
156160 'by LUCI_CONTEXT. There may be an error with this file or Gold '
157- 'authentication.' )
158- ..writeln ('Debug information for Gold:' )
159- ..writeln ('stdout: ${result .stdout }' )
160- ..writeln ('stderr: ${result .stderr }' );
161- throw Exception (buf.toString ());
161+ 'authentication.' );
162+ throw SkiaGoldProcessError (
163+ command: authCommand,
164+ stdout: result.stdout.toString (),
165+ stderr: result.stderr.toString (),
166+ message: buf.toString (),
167+ );
162168 } else if (verbose) {
163169 _stderr.writeln ('stdout:\n ${result .stdout }' );
164170 _stderr.writeln ('stderr:\n ${result .stderr }' );
@@ -193,27 +199,19 @@ interface class SkiaGoldClient {
193199 '--passfail' ,
194200 ];
195201
196- if (imgtestInitCommand.contains (null )) {
197- final StringBuffer buf = StringBuffer ()
198- ..writeln ('A null argument was provided for Skia Gold imgtest init.' )
199- ..writeln ('Please confirm the settings of your golden file test.' )
200- ..writeln ('Arguments provided:' );
201- imgtestInitCommand.forEach (buf.writeln);
202- throw Exception (buf.toString ());
203- }
204-
205202 final io.ProcessResult result = await _runCommand (imgtestInitCommand);
206203
207204 if (result.exitCode != 0 ) {
208205 final StringBuffer buf = StringBuffer ()
209206 ..writeln ('Skia Gold imgtest init failed.' )
210207 ..writeln ('An error occurred when initializing golden file test with ' )
211- ..writeln ('goldctl.' )
212- ..writeln ()
213- ..writeln ('Debug information for Gold:' )
214- ..writeln ('stdout: ${result .stdout }' )
215- ..writeln ('stderr: ${result .stderr }' );
216- throw Exception (buf.toString ());
208+ ..writeln ('goldctl.' );
209+ throw SkiaGoldProcessError (
210+ command: imgtestInitCommand,
211+ stdout: result.stdout.toString (),
212+ stderr: result.stderr.toString (),
213+ message: buf.toString (),
214+ );
217215 } else if (verbose) {
218216 _stderr.writeln ('stdout:\n ${result .stdout }' );
219217 _stderr.writeln ('stderr:\n ${result .stderr }' );
@@ -308,12 +306,13 @@ interface class SkiaGoldClient {
308306 ..writeln ('Visit https://flutter-engine-gold.skia.org/ to view and approve ' )
309307 ..writeln ('the image(s), or revert the associated change. For more ' )
310308 ..writeln ('information, visit the wiki: ' )
311- ..writeln ('https://github.com/flutter/flutter/wiki/Writing-a-golden-file-test-for-package:flutter' )
312- ..writeln ()
313- ..writeln ('Debug information for Gold --------------------------------' )
314- ..writeln ('stdout: ${result .stdout }' )
315- ..writeln ('stderr: ${result .stderr }' );
316- throw Exception (buf.toString ());
309+ ..writeln ('https://github.com/flutter/flutter/wiki/Writing-a-golden-file-test-for-package:flutter' );
310+ throw SkiaGoldProcessError (
311+ command: imgtestCommand,
312+ stdout: result.stdout.toString (),
313+ stderr: result.stderr.toString (),
314+ message: buf.toString (),
315+ );
317316 } else if (verbose) {
318317 _stderr.writeln ('stdout:\n ${result .stdout }' );
319318 _stderr.writeln ('stderr:\n ${result .stderr }' );
@@ -347,27 +346,19 @@ interface class SkiaGoldClient {
347346 ..._getCIArguments (),
348347 ];
349348
350- if (tryjobInitCommand.contains (null )) {
351- final StringBuffer buf = StringBuffer ()
352- ..writeln ('A null argument was provided for Skia Gold tryjob init.' )
353- ..writeln ('Please confirm the settings of your golden file test.' )
354- ..writeln ('Arguments provided:' );
355- tryjobInitCommand.forEach (buf.writeln);
356- throw Exception (buf.toString ());
357- }
358-
359349 final io.ProcessResult result = await _runCommand (tryjobInitCommand);
360350
361351 if (result.exitCode != 0 ) {
362352 final StringBuffer buf = StringBuffer ()
363353 ..writeln ('Skia Gold tryjobInit failure.' )
364354 ..writeln ('An error occurred when initializing golden file tryjob with ' )
365- ..writeln ('goldctl.' )
366- ..writeln ()
367- ..writeln ('Debug information for Gold:' )
368- ..writeln ('stdout: ${result .stdout }' )
369- ..writeln ('stderr: ${result .stderr }' );
370- throw Exception (buf.toString ());
355+ ..writeln ('goldctl.' );
356+ throw SkiaGoldProcessError (
357+ command: tryjobInitCommand,
358+ stdout: result.stdout.toString (),
359+ stderr: result.stderr.toString (),
360+ message: buf.toString (),
361+ );
371362 } else if (verbose) {
372363 _stderr.writeln ('stdout:\n ${result .stdout }' );
373364 _stderr.writeln ('stderr:\n ${result .stderr }' );
@@ -414,13 +405,13 @@ interface class SkiaGoldClient {
414405 final StringBuffer buf = StringBuffer ()
415406 ..writeln ('Unexpected Gold tryjobAdd failure.' )
416407 ..writeln ('Tryjob execution for golden file test $testName failed for' )
417- ..writeln ('a reason unrelated to pixel comparison.' )
418- .. writeln ()
419- .. writeln ( 'Debug information for Gold:' )
420- .. writeln ( ' stdout: ${ result . stdout }' )
421- .. writeln ( ' stderr: ${ result .stderr }' )
422- .. writeln ();
423- throw Exception (buf. toString () );
408+ ..writeln ('a reason unrelated to pixel comparison.' );
409+ throw SkiaGoldProcessError (
410+ command : tryjobCommand,
411+ stdout: resultStdout,
412+ stderr: result.stderr. toString (),
413+ message : buf. toString (),
414+ );
424415 } else if (verbose) {
425416 _stderr.writeln ('stdout:\n ${result .stdout }' );
426417 _stderr.writeln ('stderr:\n ${result .stderr }' );
@@ -489,7 +480,7 @@ interface class SkiaGoldClient {
489480 workingDirectory: engineCheckout,
490481 );
491482 if (revParse.exitCode != 0 ) {
492- throw Exception ('Current commit of the engine can not be found from path $engineCheckout .' );
483+ throw StateError ('Current commit of the engine can not be found from path $engineCheckout .' );
493484 }
494485 return (revParse.stdout as String ).trim ();
495486 }
0 commit comments