aboutsummaryrefslogtreecommitdiff
path: root/build2/test/script/parser.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2017-03-17 12:40:02 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2017-03-17 12:40:02 +0200
commit5a686c5460e9fbb32af5014d0dbf1169ea301ec2 (patch)
treeaa219f442926ef4879acb2c14f7eead47f9f3d33 /build2/test/script/parser.cxx
parentde09beabe1448e9c6b401ec9acdd69ee5bf0f0e2 (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/script/parser.cxx')
-rw-r--r--build2/test/script/parser.cxx35
1 files changed, 24 insertions, 11 deletions
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_),