Skip to content

Commit

Permalink
Assert with an error message instead of silently return empty object (S…
Browse files Browse the repository at this point in the history
…napchat#26)

Co-authored-by: Li Feng <li.feng@snapchat.com>
  • Loading branch information
finalpatch and li-feng-sc authored Nov 10, 2021
1 parent d739e42 commit c481172
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions support-lib/wasm/djinni_wasm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,10 @@ struct JsInterface {
// (interface +c)
template <typename, typename>
struct GetOrCreateCppProxy {
em::val operator() (const std::shared_ptr<I>& c) { return em::val::undefined(); }
em::val operator() (const std::shared_ptr<I>& c) {
assert(false && "Attempting to pass C++ object but interface lacks +c");
return em::val::undefined();
}
};
template <typename T>
struct GetOrCreateCppProxy<T, std::void_t<decltype(T::cppProxyMethods)>> {
Expand Down Expand Up @@ -501,7 +504,10 @@ struct JsInterface {
// (interface +w)
template <typename, typename>
struct GetOrCreateJsProxy {
std::shared_ptr<I> operator() (em::val js) { return {}; }
std::shared_ptr<I> operator() (em::val js) {
assert(false && "Attempting to pass JS object but interface lacks +w");
return {};
}
};
template <typename T>
struct GetOrCreateJsProxy<T, std::void_t<typename T::JsProxy>> {
Expand Down

0 comments on commit c481172

Please sign in to comment.