Skip to content

Commit

Permalink
Throw JSINativeException from asHostObject
Browse files Browse the repository at this point in the history
Summary:
`asHostObject` should throw a `JSINativeException` like the other `as*`
functions. This should be a safe change to make in most cases, since
this function already did not work when JSI was being provided by a
dynamic library. However, I defer to mhorowitz.

Changelog: [Fixed] Throw JSINativeException from asHostObject

Reviewed By: jpporto

Differential Revision: D36873355

fbshipit-source-id: 589ac50ebb4ecec4bacfd923d8b0795c0a6c0e34
  • Loading branch information
neildhar authored and facebook-github-bot committed Jun 23, 2022
1 parent 66c6a75 commit ef6ab3f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions ReactCommon/jsi/jsi/jsi-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,8 @@ inline std::shared_ptr<T> Object::getHostObject(Runtime& runtime) const {
template <typename T>
inline std::shared_ptr<T> Object::asHostObject(Runtime& runtime) const {
if (!isHostObject<T>(runtime)) {
detail::throwOrDie<JSError>(
runtime, "Object is not a HostObject of desired type");
detail::throwOrDie<JSINativeException>(
"Object is not a HostObject of desired type");
}
return std::static_pointer_cast<T>(runtime.getHostObject(*this));
}
Expand Down

0 comments on commit ef6ab3f

Please sign in to comment.