Skip to content

Commit

Permalink
Make argument count mismatches easier to debug.
Browse files Browse the repository at this point in the history
Add context on what was the expected number of arguments as well as the actual count.
  • Loading branch information
rubenlg authored and pmed committed Mar 8, 2023
1 parent 9d45f2f commit fa7f72a
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion v8pp/call_from_v8.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,10 @@ decltype(auto) call_from_v8(F&& func, v8::FunctionCallbackInfo<v8::Value> const&

if (args.Length() != call_traits::arg_count)
{
throw std::runtime_error("argument count does not match function definition");
throw std::runtime_error(
"Argument count does not match function definition. Expected " +
std::to_string(call_traits::arg_count) + " but got " +
std::to_string(args.Length()));
}

if constexpr (with_isolate)
Expand Down

0 comments on commit fa7f72a

Please sign in to comment.