From ae5cab7489fe014dd3aa818cf2655d7a4714af83 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Sat, 16 Dec 2017 17:42:12 +0200 Subject: Improve process execution diagnostics by reusing run_*() API --- build2/install/rule.cxx | 131 +++++++++++------------------------------------- 1 file changed, 28 insertions(+), 103 deletions(-) (limited to 'build2/install/rule.cxx') diff --git a/build2/install/rule.cxx b/build2/install/rule.cxx index 75de96f..79287f8 100644 --- a/build2/install/rule.cxx +++ b/build2/install/rule.cxx @@ -553,29 +553,14 @@ namespace build2 args.push_back (reld.c_str ()); args.push_back (nullptr); - try - { - process_path pp (process::path_search (args[0])); - - if (verb >= 2) - print_process (args); - else if (verb && verbose) - text << "install " << chd; - - process pr (pp, args.data ()); - - if (!pr.wait ()) - throw failed (); - } - catch (const process_error& e) - { - error << "unable to execute " << args[0] << ": " << e; + process_path pp (run_search (args[0])); - if (e.child) - exit (1); + if (verb >= 2) + print_process (args); + else if (verb && verbose) + text << "install " << chd; - throw failed (); - } + run (pp, args); } // install / @@ -622,29 +607,14 @@ namespace build2 args.push_back (reld.c_str ()); args.push_back (nullptr); - try - { - process_path pp (process::path_search (args[0])); + process_path pp (run_search (args[0])); - if (verb >= 2) - print_process (args); - else if (verb && verbose) - text << "install " << t; + if (verb >= 2) + print_process (args); + else if (verb && verbose) + text << "install " << t; - process pr (pp, args.data ()); - - if (!pr.wait ()) - throw failed (); - } - catch (const process_error& e) - { - error << "unable to execute " << args[0] << ": " << e; - - if (e.child) - exit (1); - - throw failed (); - } + run (pp, args); } void file_rule:: @@ -672,29 +642,14 @@ namespace build2 const char** args (&args_a[base.sudo == nullptr ? 1 : 0]); - try - { - process_path pp (process::path_search (args[0])); - - if (verb >= 2) - print_process (args); - else if (verb && verbose) - text << "install " << rell << " -> " << target; - - process pr (pp, args); - - if (!pr.wait ()) - throw failed (); - } - catch (const process_error& e) - { - error << "unable to execute " << args[0] << ": " << e; + process_path pp (run_search (args[0])); - if (e.child) - exit (1); + if (verb >= 2) + print_process (args); + else if (verb && verbose) + text << "install " << rell << " -> " << target; - throw failed (); - } + run (pp, args); } target_state file_rule:: @@ -839,29 +794,14 @@ namespace build2 const char** args (&args_a[base.sudo == nullptr ? 1 : 0]); - try - { - process_path pp (process::path_search (args[0])); - - if (verb >= 2) - print_process (args); - else if (verb && verbose) - text << "uninstall " << reld; - - process pr (pp, args); + process_path pp (run_search (args[0])); - if (!pr.wait ()) - throw failed (); - } - catch (const process_error& e) - { - error << "unable to execute " << args[0] << ": " << e; - - if (e.child) - exit (1); + if (verb >= 2) + print_process (args); + else if (verb && verbose) + text << "uninstall " << reld; - throw failed (); - } + run (pp, args); } } @@ -942,27 +882,12 @@ namespace build2 const char** args (&args_a[base.sudo == nullptr ? 1 : 0]); - try - { - process_path pp (process::path_search (args[0])); - - if (verb >= 2) - print_process (args); - - process pr (pp, args); + process_path pp (run_search (args[0])); - if (!pr.wait ()) - throw failed (); - } - catch (const process_error& e) - { - error << "unable to execute " << args[0] << ": " << e; - - if (e.child) - exit (1); + if (verb >= 2) + print_process (args); - throw failed (); - } + run (pp, args); } return true; -- cgit v1.1