Skip to content

Commit

Permalink
fix: Add workaround for error messages on Android (#408)
Browse files Browse the repository at this point in the history
  • Loading branch information
mrousavy authored Dec 9, 2024
1 parent 3ccafbc commit 27e8cbb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,14 @@ class HybridFunction final {
std::string funcName = getHybridFuncFullName<THybrid>(kind, name, hybridInstance.get());
std::string message = exception.what();
throw jsi::JSError(runtime, funcName + ": " + message);
#ifdef ANDROID
// Workaround for https://github.com/mrousavy/nitro/issues/382
} catch (const std::runtime_error& exception) {
// Some exception was thrown - add method name information and re-throw as `JSError`.
std::string funcName = getHybridFuncFullName<THybrid>(kind, name, hybridInstance.get());
std::string message = exception.what();
throw jsi::JSError(runtime, funcName + ": " + message);
#endif
} catch (...) {
// Some unknown exception was thrown - add method name information and re-throw as `JSError`.
std::string funcName = getHybridFuncFullName<THybrid>(kind, name, hybridInstance.get());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ struct JSIConverter<std::exception_ptr> final {
} catch (const std::exception& e) {
jsi::JSError error(runtime, e.what());
return jsi::Value(runtime, error.value());
#ifdef ANDROID
// Workaround for https://github.com/mrousavy/nitro/issues/382
} catch (const std::exception& e) {
jsi::JSError error(runtime, e.what());
return jsi::Value(runtime, error.value());
#endif
} catch (...) {
// Some unknown exception was thrown - maybe an Objective-C error?
std::string errorName = TypeInfo::getCurrentExceptionName();
Expand Down

0 comments on commit 27e8cbb

Please sign in to comment.