Skip to content

fix: fix exception handling in C++ native code #244

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: @jakubgonera/style-transfer-cpp
Choose a base branch
from

Conversation

JakubGonera
Copy link
Contributor

Description

Fix exception handling in C++ native code so that it results in JS promise getting rejected with an appropriate message. There are two fixes here:

  1. Runtime type information in the current version of React Native is disabled because one of its dependencies, which results in C++ not being able to recognize that std::runtime_error is inheriting from std::exception so to extract the exception message we need to match the type exactly. A fix has been introduced in RN repo, but not yet present in any release: facebook/react-native@3132cc8.
  2. When rejecting a promise the old code was accessing JS runtime in an unsafe way, this is fixed now.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update (improves or adds clarity to existing documentation)

Tested on

  • iOS
  • Android

@JakubGonera JakubGonera force-pushed the @jakubgonera/style-transfer-exceptions branch from 63172e6 to 0fd19e3 Compare May 7, 2025 11:13
@JakubGonera JakubGonera marked this pull request as ready for review May 7, 2025 11:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Handle errors in C++ native code gracefully Port style transfer model to C++
3 participants