@@ -61,20 +61,26 @@ void main(List<String> args) {
6161 }
6262
6363 // Run clangd.
64- final io.ProcessResult result = io.Process .runSync (clangd, < String > [
65- '--compile-commands-dir' ,
66- compileCommandsDir,
67- '--check=$checkFile ' ,
68- ]);
69- io.stdout.write (result.stdout);
70- io.stderr.write (result.stderr);
71- if ((result.stderr as String ).contains ('Path specified by --compile-commands-dir does not exist' )) {
72- io.stdout.writeln ('clangd_check failed: --compile-commands-dir does not exist' );
64+ try {
65+ final io.ProcessResult result = io.Process .runSync (clangd, < String > [
66+ '--compile-commands-dir' ,
67+ compileCommandsDir,
68+ '--check=$checkFile ' ,
69+ ]);
70+ io.stdout.write (result.stdout);
71+ io.stderr.write (result.stderr);
72+ if ((result.stderr as String ).contains ('Path specified by --compile-commands-dir does not exist' )) {
73+ io.stdout.writeln ('clangd_check failed: --compile-commands-dir does not exist' );
74+ io.exitCode = 1 ;
75+ } else if ((result.stderr as String ).contains ('Failed to resolve path' )) {
76+ io.stdout.writeln ('clangd_check failed: --check file does not exist' );
77+ io.exitCode = 1 ;
78+ } else {
79+ io.exitCode = result.exitCode;
80+ }
81+ } on io.ProcessException catch (e) {
82+ io.stderr.writeln ('Failed to run clangd: $e ' );
83+ io.stderr.writeln (const JsonEncoder .withIndent (' ' ).convert (entry));
7384 io.exitCode = 1 ;
74- } else if ((result.stderr as String ).contains ('Failed to resolve path' )) {
75- io.stdout.writeln ('clangd_check failed: --check file does not exist' );
76- io.exitCode = 1 ;
77- } else {
78- io.exitCode = result.exitCode;
7985 }
8086}
0 commit comments