more detailed CxxModule logging
Summary: <!-- Thank you for sending the PR! We appreciate you spending the time to work on these changes. Help us understand your motivation by explaining why you decided to make this change. You can learn more about contributing to React Native here: http://facebook.github.io/react-native/docs/contributing.html Happy contributing! --> Cxx module code swallows c++ exception details with sarcastic comment let native developer figure it out. Now instead of swallowing it, we print as much information as we can for different exception types. Still not ideal but way more informative. Have a crash in your c++ module and try to figure it out without this change. Closes https://github.com/facebook/react-native/pull/16193 Differential Revision: D6040038 Pulled By: javache fbshipit-source-id: 3fbe838383ca13395e21f74c9549474f6329cfeb
This commit is contained in:
Родитель
224d29447f
Коммит
4192790f05
|
@ -4,7 +4,7 @@
|
||||||
#include "Instance.h"
|
#include "Instance.h"
|
||||||
|
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
|
#include <glog/logging.h>
|
||||||
#include <folly/json.h>
|
#include <folly/json.h>
|
||||||
|
|
||||||
#include "JsArgumentHelpers.h"
|
#include "JsArgumentHelpers.h"
|
||||||
|
@ -12,7 +12,6 @@
|
||||||
#include "MessageQueueThread.h"
|
#include "MessageQueueThread.h"
|
||||||
|
|
||||||
using facebook::xplat::module::CxxModule;
|
using facebook::xplat::module::CxxModule;
|
||||||
|
|
||||||
namespace facebook {
|
namespace facebook {
|
||||||
namespace react {
|
namespace react {
|
||||||
|
|
||||||
|
@ -140,9 +139,14 @@ void CxxNativeModule::invoke(unsigned int reactMethodId, folly::dynamic&& params
|
||||||
method.func(std::move(params), first, second);
|
method.func(std::move(params), first, second);
|
||||||
} catch (const facebook::xplat::JsArgumentException& ex) {
|
} catch (const facebook::xplat::JsArgumentException& ex) {
|
||||||
throw;
|
throw;
|
||||||
|
} catch (std::exception& e) {
|
||||||
|
LOG(ERROR) << "std::exception. Method call " << method.name.c_str() << " failed: " << e.what();
|
||||||
|
std::terminate();
|
||||||
|
} catch (std::string& error) {
|
||||||
|
LOG(ERROR) << "std::string. Method call " << method.name.c_str() << " failed: " << error.c_str();
|
||||||
|
std::terminate();
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
// This means some C++ code is buggy. As above, we fail hard so the C++
|
LOG(ERROR) << "Method call " << method.name.c_str() << " failed. unknown error";
|
||||||
// developer can debug and fix it.
|
|
||||||
std::terminate();
|
std::terminate();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Загрузка…
Ссылка в новой задаче