[native] Avoid calling invariant from worklet
Summary:
While working on testing D10553, I noticed the following error:
This regression was caused by my changes in D10004. I added an invariant to satisfy Flow there, but I didn't consider that I was adding a function call to a worklet. Reanimated worklets can only call other functions that are worklets; otherwise, the call should be proxied via runOnJS.
This diff updates the call to just throw new Error instance, which works just as well for Flow. I'm not sure if using Error within a worklet will cause an issue, but it shouldn't matter because the control flow should never enter this conditional, and if it does then we're going to be erroring anyways.
Test Plan: Before this diff, swiping a message would trigger the error in the screenshot above. After this diff, the error is no longer triggered.
Reviewers: ginsu, atul, will
Reviewed By: atul, will
Subscribers: tomek
Differential Revision: https://phab.comm.dev/D10554