mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
84225573c1
Summary: Changelog: [Internal][Added] 1/n Add new JsErrorHandler buck target to parse JS errors in C++ This JsErrorHandler.cpp class uses the same regex logic as [stack-trace-parser.js](https://github.com/errwischt/stacktrace-parser/blob/master/src/stack-trace-parser.js#L121) in order to parse JS errors into an array of stack frames. In RN, stacktrace-parser is called from [Devtools/parseErrorStack.js](https://github.com/facebook/react-native/blob/8bd3edec88148d0ab1f225d2119435681fbbba33/Libraries/Core/Devtools/parseErrorStack.js#L46). Reviewed By: sammy-SC Differential Revision: D40296024 fbshipit-source-id: 8e1b034e8a1ee1a8cc808bfc36c7104a8f40f9cc
38 lines
965 B
C++
38 lines
965 B
C++
/*
|
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*/
|
|
|
|
#include <jsi/jsi.h>
|
|
#include <react/renderer/mapbuffer/MapBuffer.h>
|
|
|
|
namespace facebook {
|
|
namespace react {
|
|
|
|
const int FILE_KEY_OF_JS_ERROR = 0;
|
|
const int METHOD_NAME_KEY_OF_JS_ERROR = 1;
|
|
const int LINE_NUMBER_KEY_OF_JS_ERROR = 2;
|
|
const int COLUMN_KEY_OF_JS_ERROR = 3;
|
|
const int FRAMES_KEY_OF_JS_ERROR = 4;
|
|
const int MESSAGE_KEY_OF_JS_ERROR = 5;
|
|
const int ID_KEY_OF_JS_ERROR = 6;
|
|
const int IS_FATAL_KEY_OF_JS_ERROR = 7;
|
|
|
|
class JsErrorHandler {
|
|
public:
|
|
using JsErrorHandlingFunc = std::function<void(MapBuffer errorMap)>;
|
|
|
|
JsErrorHandler(JsErrorHandlingFunc jsErrorHandlingFunc);
|
|
~JsErrorHandler();
|
|
|
|
void handleJsError(const jsi::JSError &error, bool isFatal);
|
|
|
|
private:
|
|
JsErrorHandlingFunc _jsErrorHandlingFunc;
|
|
};
|
|
|
|
} // namespace react
|
|
} // namespace facebook
|