@@ -57,60 +57,47 @@ async fn run() -> CLIResult<()> {
5757 let ( _, mut results) = async_scoped:: TokioScope :: scope_and_block ( |scope| {
5858 for input in inputs {
5959 scope. spawn ( async {
60- let result: CLIResult < ( ) > = match input {
61- Ok ( input) => {
62- let language = cache. fetch ( & input) . await ?;
63- let output = OutputFile :: try_from ( & input) ?;
64-
65- log:: info!(
66- "Formatting {}, as {} using {}, to {}" ,
67- input. source( ) ,
68- input. language( ) . name,
69- input. query( ) ,
70- output
71- ) ;
72-
73- let mut buf_output = BufWriter :: new ( output) ;
74-
75- {
76- // NOTE This newly opened scope is important! `buf_input` takes
77- // ownership of `input`, which -- upon reading -- contains an
78- // open file handle. We need to close this file, by dropping
79- // `buf_input`, before we attempt to persist our output.
80- // Otherwise, we get an exclusive lock problem on Windows.
81- let mut buf_input = BufReader :: new ( input) ;
82-
83- formatter (
84- & mut buf_input,
85- & mut buf_output,
86- & language,
87- Operation :: Format {
88- skip_idempotence,
89- tolerate_parsing_errors,
90- } ,
91- )
92- . map_err ( |e| {
93- e. with_location ( format ! ( "{}" , buf_input. get_ref( ) . source( ) ) )
94- } ) ?;
95- }
96-
97- buf_output. into_inner ( ) ?. persist ( ) ?;
98-
99- Ok ( ( ) )
100- }
101-
102- // This happens when the input resolver cannot establish an input
103- // source, language or query file.
104- Err ( error) => Err ( error) ,
105- } ;
106-
107- if let Err ( error) = & result {
108- // By this point, we've lost any reference to the original
109- // input; we trust that it is embedded into `error`.
110- log:: warn!( "Skipping: {error}" ) ;
60+ // This happens when the input resolver cannot establish an input
61+ // source, language or query file.
62+ let input = input?;
63+ let language = cache. fetch ( & input) . await ?;
64+ let output = OutputFile :: try_from ( & input) ?;
65+
66+ log:: info!(
67+ "Formatting {}, as {} using {}, to {}" ,
68+ input. source( ) ,
69+ input. language( ) . name,
70+ input. query( ) ,
71+ output
72+ ) ;
73+
74+ let mut buf_output = BufWriter :: new ( output) ;
75+
76+ {
77+ // NOTE This newly opened scope is important! `buf_input` takes
78+ // ownership of `input`, which -- upon reading -- contains an
79+ // open file handle. We need to close this file, by dropping
80+ // `buf_input`, before we attempt to persist our output.
81+ // Otherwise, we get an exclusive lock problem on Windows.
82+ let mut buf_input = BufReader :: new ( input) ;
83+
84+ formatter (
85+ & mut buf_input,
86+ & mut buf_output,
87+ & language,
88+ Operation :: Format {
89+ skip_idempotence,
90+ tolerate_parsing_errors,
91+ } ,
92+ )
93+ . map_err ( |e| {
94+ e. with_location ( format ! ( "{}" , buf_input. get_ref( ) . source( ) ) )
95+ } ) ?;
11196 }
11297
113- result
98+ buf_output. into_inner ( ) ?. persist ( ) ?;
99+
100+ CLIResult :: Ok ( ( ) )
114101 } ) ;
115102 }
116103 } ) ;
@@ -120,6 +107,15 @@ async fn run() -> CLIResult<()> {
120107 results. remove ( 0 ) ??
121108 } else if results
122109 . iter ( )
110+ . inspect ( |r| match r {
111+ Err ( e) => print_error ( & e) ,
112+ Ok ( Err ( e) ) => {
113+ if !e. benign ( ) {
114+ print_error ( & e)
115+ }
116+ }
117+ _ => { }
118+ } )
123119 . any ( |result| matches ! ( result, Err ( _) | Ok ( Err ( _) ) ) )
124120 {
125121 // For multiple inputs, bail out if any failed with a "multiple errors" failure
0 commit comments