@@ -78,24 +78,24 @@ pub async fn run_foreground(config_path: Option<PathBuf>, with_setup: bool) -> R
7878
7979pub fn helper_start ( config_path : Option < PathBuf > ) -> Result < ( ) > {
8080 let paths = resolve_paths ( config_path) ?;
81- let config = AppConfig :: load_or_create ( & paths. config_path ) ?;
82- ensure_elevated ( & config, true ) ?;
81+ let start_result = ( || -> Result < ( ) > {
82+ let config = AppConfig :: load_or_create ( & paths. config_path ) ?;
83+ ensure_elevated ( & config, true ) ?;
8384
84- let current = state:: refresh ( & paths) ?;
85- if current. running {
86- return Ok ( ( ) ) ;
87- }
85+ let current = state:: refresh ( & paths) ?;
86+ if current. running {
87+ return Ok ( ( ) ) ;
88+ }
8889
89- let bundle = ensure_bundle ( & config, & paths. cert_dir ) ?;
90- #[ cfg( not( target_os = "macos" ) ) ]
91- install_ca ( & bundle. ca_cert_path , & config. ca_common_name ) ?;
92- #[ cfg( target_os = "macos" ) ]
93- let _ = bundle;
94- apply_hosts ( & config) ?;
95- state:: mark_starting ( & paths) ?;
90+ let bundle = ensure_bundle ( & config, & paths. cert_dir ) ?;
91+ #[ cfg( not( target_os = "macos" ) ) ]
92+ install_ca ( & bundle. ca_cert_path , & config. ca_common_name ) ?;
93+ #[ cfg( target_os = "macos" ) ]
94+ let _ = bundle;
95+ apply_hosts ( & config) ?;
96+ state:: mark_starting ( & paths) ?;
9697
97- let cli_binary = current_cli_binary ( ) ?;
98- let start_result = ( || -> Result < ( ) > {
98+ let cli_binary = current_cli_binary ( ) ?;
9999 let args = vec ! [
100100 "--config" . to_string( ) ,
101101 paths. config_path. to_string_lossy( ) . into_owned( ) ,
@@ -116,14 +116,13 @@ pub fn helper_start(config_path: Option<PathBuf>) -> Result<()> {
116116 Ok ( ( ) )
117117 } ) ( ) ;
118118
119- if let Err ( error) = start_result {
119+ if let Err ( error) = & start_result {
120120 let _ = remove_hosts ( ) ;
121121 let _ = state:: clear_pid ( & paths) ;
122- let _ = state:: mark_error ( & paths, & error. to_string ( ) ) ;
123- return Err ( error) ;
122+ let _ = state:: mark_error ( & paths, & format ! ( "{error:#}" ) ) ;
124123 }
125124
126- Ok ( ( ) )
125+ start_result
127126}
128127
129128pub fn helper_stop ( config_path : Option < PathBuf > ) -> Result < ( ) > {
0 commit comments