From 508729ec77949d801229a38f951c46985532bebc Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Wed, 26 Oct 2016 10:08:53 -0600 Subject: [PATCH] Properly handle error reporting with method_missing --- include/chaiscript/dispatchkit/dispatchkit.hpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/include/chaiscript/dispatchkit/dispatchkit.hpp b/include/chaiscript/dispatchkit/dispatchkit.hpp index f9d3485..cb61a91 100644 --- a/include/chaiscript/dispatchkit/dispatchkit.hpp +++ b/include/chaiscript/dispatchkit/dispatchkit.hpp @@ -963,14 +963,20 @@ namespace chaiscript This_Foist fi(*this, l_params.front()); - auto func = boxed_cast>(bv); try { - return (*func)({l_params.begin() + l_num_params, l_params.end()}, l_conversions); + auto func = boxed_cast>(bv); + try { + return (*func)({l_params.begin() + l_num_params, l_params.end()}, l_conversions); + } catch (const chaiscript::exception::bad_boxed_cast &) { + } catch (const chaiscript::exception::arity_error &) { + } catch (const chaiscript::exception::guard_error &) { + } + throw chaiscript::exception::dispatch_error({l_params.begin() + l_num_params, l_params.end()}, std::vector{func}); } catch (const chaiscript::exception::bad_boxed_cast &) { - } catch (const chaiscript::exception::arity_error &) { - } catch (const chaiscript::exception::guard_error &) { + // unable to convert bv into a Proxy_Function_Base + throw chaiscript::exception::dispatch_error({l_params.begin() + l_num_params, l_params.end()}, + std::vector(l_funs.begin(), l_funs.end())); } - throw chaiscript::exception::dispatch_error({l_params.begin() + l_num_params, l_params.end()}, std::vector{func}); } else { return bv; }