@@ -10,7 +10,7 @@ use std::{io, process};
1010
1111use crate :: common:: SudoPath ;
1212use crate :: exec:: ExitReason ;
13- use crate :: log:: user_info;
13+ use crate :: log:: { user_error , user_info} ;
1414use crate :: system:: file:: { create_temporary_dir, FileLock } ;
1515use crate :: system:: wait:: { Wait , WaitError , WaitOptions } ;
1616use crate :: system:: { fork, ForkResult } ;
@@ -157,8 +157,8 @@ struct TempDirDropGuard(PathBuf);
157157impl Drop for TempDirDropGuard {
158158 fn drop ( & mut self ) {
159159 if let Err ( e) = std:: fs:: remove_dir_all ( & self . 0 ) {
160- eprintln_ignore_io_error ! (
161- "Failed to remove temporary directory {}: {e}" ,
160+ user_error ! (
161+ "failed to remove temporary directory {}: {e}" ,
162162 self . 0 . display( ) ,
163163 ) ;
164164 } ;
@@ -169,7 +169,7 @@ fn handle_child(editor: &Path, file: Vec<ChildFileInfo<'_>>) -> ! {
169169 match handle_child_inner ( editor, file) {
170170 Ok ( ( ) ) => process:: exit ( 0 ) ,
171171 Err ( err) => {
172- eprintln_ignore_io_error ! ( "{err}" ) ;
172+ user_error ! ( "{err}" ) ;
173173 process:: exit ( 1 ) ;
174174 }
175175 }
@@ -184,15 +184,15 @@ fn handle_child_inner(editor: &Path, mut files: Vec<ChildFileInfo<'_>>) -> Resul
184184 }
185185
186186 let tempdir = TempDirDropGuard (
187- create_temporary_dir ( ) . map_err ( |e| format ! ( "Failed to create temporary directory: {e}" ) ) ?,
187+ create_temporary_dir ( ) . map_err ( |e| format ! ( "failed to create temporary directory: {e}" ) ) ?,
188188 ) ;
189189
190190 for ( i, file) in files. iter_mut ( ) . enumerate ( ) {
191191 // Create temp file
192192 let dir = tempdir. 0 . join ( format ! ( "{i}" ) ) ;
193193 std:: fs:: create_dir ( & dir) . map_err ( |e| {
194194 format ! (
195- "Failed to create temporary directory {}: {e}" ,
195+ "failed to create temporary directory {}: {e}" ,
196196 dir. display( ) ,
197197 )
198198 } ) ?;
@@ -205,15 +205,15 @@ fn handle_child_inner(editor: &Path, mut files: Vec<ChildFileInfo<'_>>) -> Resul
205205 . open ( & tempfile_path)
206206 . map_err ( |e| {
207207 format ! (
208- "Failed to create temporary file {}: {e}" ,
208+ "failed to create temporary file {}: {e}" ,
209209 tempfile_path. display( ) ,
210210 )
211211 } ) ?;
212212
213213 // Write to temp file
214214 tempfile. write_all ( & file. old_data ) . map_err ( |e| {
215215 format ! (
216- "Failed to write to temporary file {}: {e}" ,
216+ "failed to write to temporary file {}: {e}" ,
217217 tempfile_path. display( ) ,
218218 )
219219 } ) ?;
@@ -229,7 +229,7 @@ fn handle_child_inner(editor: &Path, mut files: Vec<ChildFileInfo<'_>>) -> Resul
229229 . map ( |file| file. tempfile_path . as_ref ( ) . expect ( "filled in above" ) ) ,
230230 )
231231 . status ( )
232- . map_err ( |e| format ! ( "Failed to run editor {}: {e}" , editor. display( ) ) ) ?;
232+ . map_err ( |e| format ! ( "failed to run editor {}: {e}" , editor. display( ) ) ) ?;
233233
234234 if !status. success ( ) {
235235 drop ( tempdir) ;
@@ -246,15 +246,15 @@ fn handle_child_inner(editor: &Path, mut files: Vec<ChildFileInfo<'_>>) -> Resul
246246 // Read from temp file
247247 let new_data = std:: fs:: read ( tempfile_path) . map_err ( |e| {
248248 format ! (
249- "Failed to read from temporary file {}: {e}" ,
249+ "failed to read from temporary file {}: {e}" ,
250250 tempfile_path. display( ) ,
251251 )
252252 } ) ?;
253253
254254 // FIXME preserve temporary file if the original couldn't be written to
255255 std:: fs:: remove_file ( tempfile_path) . map_err ( |e| {
256256 format ! (
257- "Failed to remove temporary file {}: {e}" ,
257+ "failed to remove temporary file {}: {e}" ,
258258 tempfile_path. display( ) ,
259259 )
260260 } ) ?;
@@ -271,11 +271,11 @@ fn handle_child_inner(editor: &Path, mut files: Vec<ChildFileInfo<'_>>) -> Resul
271271 ) {
272272 Ok ( b'y' ) => { }
273273 _ => {
274- eprintln_ignore_io_error ! ( "Not overwriting {}" , file. path. display( ) ) ;
274+ user_info ! ( "not overwriting {}" , file. path. display( ) ) ;
275275
276276 // Parent ignores write when new data matches old data
277277 write_stream ( & mut file. new_data_tx , & file. old_data )
278- . map_err ( |e| format ! ( "Failed to write data to parent: {e}" ) ) ?;
278+ . map_err ( |e| format ! ( "failed to write data to parent: {e}" ) ) ?;
279279
280280 continue ;
281281 }
@@ -284,7 +284,7 @@ fn handle_child_inner(editor: &Path, mut files: Vec<ChildFileInfo<'_>>) -> Resul
284284
285285 // Write to socket
286286 write_stream ( & mut file. new_data_tx , & new_data)
287- . map_err ( |e| format ! ( "Failed to write data to parent: {e}" ) ) ?;
287+ . map_err ( |e| format ! ( "failed to write data to parent: {e}" ) ) ?;
288288 }
289289
290290 process:: exit ( 0 ) ;
0 commit comments