Skip to content

Commit

Permalink
Fallback to toString when getErrorDescription fails
Browse files Browse the repository at this point in the history
Summary: Fallback to the previous toString call when `getErrorDescription` fails (for unknown reasons).

Reviewed By: mhorowitz

Differential Revision: D64693634

fbshipit-source-id: e9fe72663717b3808885457c16577254b8bd995c
  • Loading branch information
javache authored and facebook-github-bot committed Oct 22, 2024
1 parent 89dc482 commit d5a9092
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions cxx/fbjni/detail/Exceptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -425,8 +425,8 @@ local_ref<JThrowable> JniException::getThrowable() const noexcept {

// TODO 6900503: consider making this thread-safe.
void JniException::populateWhat() const noexcept {
ThreadScope ts;
try {
ThreadScope ts;
static auto exceptionHelperClass =
findClassStatic("com/facebook/jni/ExceptionHelper");
static auto getErrorDescriptionMethod =
Expand All @@ -436,7 +436,12 @@ void JniException::populateWhat() const noexcept {
->toStdString();
isMessageExtracted_ = true;
} catch (...) {
what_ = kExceptionMessageFailure;
try {
what_ = throwable_->toString();
isMessageExtracted_ = true;
} catch (...) {
what_ = kExceptionMessageFailure;
}
}
}

Expand Down

0 comments on commit d5a9092

Please sign in to comment.