diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2017-03-17 12:40:02 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2017-03-17 12:40:02 +0200 |
commit | 5a686c5460e9fbb32af5014d0dbf1169ea301ec2 (patch) | |
tree | aa219f442926ef4879acb2c14f7eead47f9f3d33 /build2/test | |
parent | de09beabe1448e9c6b401ec9acdd69ee5bf0f0e2 (diff) |
Catch and dump unhandled exceptions in async task functions
The problem with relying on noexcept for this is that there is no stack.
Diffstat (limited to 'build2/test')
-rw-r--r-- | build2/test/rule.cxx | 6 | ||||
-rw-r--r-- | build2/test/script/parser.cxx | 35 |
2 files changed, 30 insertions, 11 deletions
diff --git a/build2/test/rule.cxx b/build2/test/rule.cxx index 5cec891..0e1aff6 100644 --- a/build2/test/rule.cxx +++ b/build2/test/rule.cxx @@ -397,6 +397,12 @@ namespace build2 { r = scope_state::failed; } + catch (const std::exception& e) + { + *diag_stream << "unhandled exception: " << e; + assert (false); + abort (); + } return r; } diff --git a/build2/test/script/parser.cxx b/build2/test/script/parser.cxx index d004223..0555f2f 100644 --- a/build2/test/script/parser.cxx +++ b/build2/test/script/parser.cxx @@ -2867,6 +2867,26 @@ namespace build2 exec_scope_body (); } + static void + execute_impl (scope& s, script& scr, runner& r) noexcept + { + try + { + parser p; + p.execute (s, scr, r); + } + catch (const failed&) + { + s.state = scope_state::failed; + } + catch (const std::exception& e) + { + *diag_stream << "unhandled exception: " << e; + assert (false); + abort (); + } + } + void parser:: exec_scope_body () { @@ -2983,20 +3003,13 @@ namespace build2 // bail out if we weren't asked to keep going. // if (!sched.async (task_count, - [] (scope& s, script& scr, runner& r, + [] (scope& s, + script& scr, + runner& r, const diag_frame* ds) noexcept { diag_frame df (ds); - - try - { - parser p; - p.execute (s, scr, r); - } - catch (const failed&) - { - s.state = scope_state::failed; - } + execute_impl (s, scr, r); }, ref (*chain), ref (*script_), |