diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2018-10-23 09:52:46 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2018-10-23 09:52:46 +0200 |
commit | 030035bd25b3ededb2f78be1f576f2fe0e7d9c90 (patch) | |
tree | bd1e9ed7a0218a306faa41fff52124b6848a3fc3 /build2/function.cxx | |
parent | 83459829f24624e3cee20a7199af5c69e9678b69 (diff) |
Move invalid_argument handler from default_thunk() to call()
This way we let a custom thunk catch derived exception (like invalid_path).
Diffstat (limited to 'build2/function.cxx')
-rw-r--r-- | build2/function.cxx | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/build2/function.cxx b/build2/function.cxx index 44bda57..47d4733 100644 --- a/build2/function.cxx +++ b/build2/function.cxx @@ -238,7 +238,20 @@ namespace build2 } } - return make_pair (f->impl (base, move (args), *f), true); + try + { + return make_pair (f->impl (base, move (args), *f), true); + } + catch (const invalid_argument& e) + { + diag_record dr (fail); + dr << "invalid argument"; + + if (*e.what () != '\0') + dr << ": " << e; + + dr << endf; + } } case 0: { @@ -298,7 +311,6 @@ namespace build2 default_thunk (const scope* base, vector_view<value> args, const function_overload& f) - try { // Call the cast thunk. // @@ -310,16 +322,6 @@ namespace build2 auto d (reinterpret_cast<const cast_data*> (&f.data)); return d->thunk (base, move (args), d); } - catch (const invalid_argument& e) - { - diag_record dr (fail); - dr << "invalid argument"; - - if (*e.what () != '\0') - dr << ": " << e; - - dr << endf; - } #if !defined(_MSC_VER) || _MSC_VER > 1910 constexpr const optional<const value_type*>* function_args<>::types; |