File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -344,19 +344,17 @@ impl App {
344344 print_progress ( & format ! ( "Opening {} in {}..." , file_path. display( ) , editor) ) ;
345345
346346 let status = Command :: new ( & editor) . arg ( file_path) . status ( ) . map_err ( |e| {
347- SizelintError :: config_invalid (
348- "editor" . to_string ( ) ,
349- editor. clone ( ) ,
350- format ! ( "Failed to start editor: {e}" ) ,
351- )
347+ SizelintError :: EditorExec {
348+ editor : editor. clone ( ) ,
349+ source : e,
350+ }
352351 } ) ?;
353352
354353 if !status. success ( ) {
355- return Err ( SizelintError :: config_invalid (
356- "editor" . to_string ( ) ,
354+ return Err ( SizelintError :: EditorFailed {
357355 editor,
358- "Editor exited with error" . to_string ( ) ,
359- ) ) ;
356+ exit_code : status . code ( ) . unwrap_or ( - 1 ) ,
357+ } ) ;
360358 }
361359
362360 print_success ( "Configuration saved" ) ;
Original file line number Diff line number Diff line change @@ -69,6 +69,21 @@ pub enum SizelintError {
6969 source : std:: io:: Error ,
7070 } ,
7171
72+ #[ error( "Failed to start editor '{editor}'" ) ]
73+ #[ diagnostic(
74+ code( sizelint:: editor:: exec) ,
75+ help( "Check that the editor is installed and on your PATH, or set $VISUAL / $EDITOR" )
76+ ) ]
77+ EditorExec {
78+ editor : String ,
79+ #[ source]
80+ source : std:: io:: Error ,
81+ } ,
82+
83+ #[ error( "Editor '{editor}' exited with status {exit_code}" ) ]
84+ #[ diagnostic( code( sizelint:: editor:: failed) ) ]
85+ EditorFailed { editor : String , exit_code : i32 } ,
86+
7287 #[ error( "Invalid size format '{input}': {reason}" ) ]
7388 #[ diagnostic(
7489 code( sizelint:: rule:: invalid_size_format) ,
You can’t perform that action at this time.
0 commit comments