diff --git a/packages/react-native/ReactAndroid/api/ReactAndroid.api b/packages/react-native/ReactAndroid/api/ReactAndroid.api index 45e56e949b3279..1aacea0abf949a 100644 --- a/packages/react-native/ReactAndroid/api/ReactAndroid.api +++ b/packages/react-native/ReactAndroid/api/ReactAndroid.api @@ -2364,7 +2364,7 @@ public class com/facebook/react/devsupport/StackTraceHelper { public static fun convertJsStackTrace (Lcom/facebook/react/bridge/ReadableArray;)[Lcom/facebook/react/devsupport/interfaces/StackFrame; public static fun convertJsStackTrace (Ljava/lang/String;)[Lcom/facebook/react/devsupport/interfaces/StackFrame; public static fun convertJsStackTrace (Lorg/json/JSONArray;)[Lcom/facebook/react/devsupport/interfaces/StackFrame; - public static fun convertParsedError (Lcom/facebook/react/interfaces/exceptionmanager/ReactJsExceptionHandler$ParsedError;)Lcom/facebook/react/bridge/JavaOnlyMap; + public static fun convertProcessedError (Lcom/facebook/react/interfaces/exceptionmanager/ReactJsExceptionHandler$ProcessedError;)Lcom/facebook/react/bridge/JavaOnlyMap; public static fun formatFrameSource (Lcom/facebook/react/devsupport/interfaces/StackFrame;)Ljava/lang/String; public static fun formatStackTrace (Ljava/lang/String;[Lcom/facebook/react/devsupport/interfaces/StackFrame;)Ljava/lang/String; } @@ -2816,7 +2816,7 @@ public abstract interface class com/facebook/react/interfaces/TaskInterface { public abstract fun waitForCompletion (JLjava/util/concurrent/TimeUnit;)Z } -public abstract interface class com/facebook/react/interfaces/exceptionmanager/ReactJsExceptionHandler$ParsedError { +public abstract interface class com/facebook/react/interfaces/exceptionmanager/ReactJsExceptionHandler$ProcessedError { public abstract fun getComponentStack ()Ljava/lang/String; public abstract fun getExtraData ()Lcom/facebook/react/bridge/ReadableMap; public abstract fun getId ()I @@ -2827,7 +2827,7 @@ public abstract interface class com/facebook/react/interfaces/exceptionmanager/R public abstract fun isFatal ()Z } -public abstract interface class com/facebook/react/interfaces/exceptionmanager/ReactJsExceptionHandler$ParsedError$StackFrame { +public abstract interface class com/facebook/react/interfaces/exceptionmanager/ReactJsExceptionHandler$ProcessedError$StackFrame { public abstract fun getColumn ()Ljava/lang/Integer; public abstract fun getFile ()Ljava/lang/String; public abstract fun getLineNumber ()Ljava/lang/Integer; diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/StackTraceHelper.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/StackTraceHelper.java index d901f8b2f73c79..21409bd9eb0a39 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/StackTraceHelper.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/StackTraceHelper.java @@ -15,7 +15,7 @@ import com.facebook.react.bridge.ReadableType; import com.facebook.react.common.MapBuilder; import com.facebook.react.devsupport.interfaces.StackFrame; -import com.facebook.react.interfaces.exceptionmanager.ReactJsExceptionHandler.ParsedError; +import com.facebook.react.interfaces.exceptionmanager.ReactJsExceptionHandler.ProcessedError; import java.io.File; import java.util.ArrayList; import java.util.List; @@ -263,10 +263,10 @@ public static String formatStackTrace(String title, StackFrame[] stack) { return stackTrace.toString(); } - public static JavaOnlyMap convertParsedError(ParsedError error) { - List frames = error.getStack(); + public static JavaOnlyMap convertProcessedError(ProcessedError error) { + List frames = error.getStack(); List readableMapList = new ArrayList<>(); - for (ParsedError.StackFrame frame : frames) { + for (ProcessedError.StackFrame frame : frames) { JavaOnlyMap map = new JavaOnlyMap(); map.putDouble(COLUMN_KEY, frame.getColumn()); map.putDouble(LINE_NUMBER_KEY, frame.getLineNumber()); diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/interfaces/exceptionmanager/ReactJsExceptionHandler.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/interfaces/exceptionmanager/ReactJsExceptionHandler.kt index 60113e7e6bdb35..84451ba42324a6 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/interfaces/exceptionmanager/ReactJsExceptionHandler.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/interfaces/exceptionmanager/ReactJsExceptionHandler.kt @@ -17,7 +17,7 @@ import java.util.ArrayList @UnstableReactNativeAPI public fun interface ReactJsExceptionHandler { @DoNotStripAny - public interface ParsedError { + public interface ProcessedError { @DoNotStripAny public interface StackFrame { public val file: String? @@ -37,24 +37,24 @@ public fun interface ReactJsExceptionHandler { } @DoNotStripAny - private data class ParsedStackFrameImpl( + private data class ProcessedErrorStackFrameImpl( override val file: String?, override val methodName: String, override val lineNumber: Int?, override val column: Int?, - ) : ParsedError.StackFrame + ) : ProcessedError.StackFrame @DoNotStripAny - private data class ParsedErrorImpl( + private data class ProcessedErrorImpl( override val message: String, override val originalMessage: String?, override val name: String?, override val componentStack: String?, - override val stack: ArrayList, + override val stack: ArrayList, override val id: Int, override val isFatal: Boolean, override val extraData: ReadableNativeMap, - ) : ParsedError + ) : ProcessedError - public fun reportJsException(errorMap: ParsedError) + public fun reportJsException(errorMap: ProcessedError) } diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/ReactInstance.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/ReactInstance.java index 53cd2ee20c8b79..6eb8a75c63a84a 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/ReactInstance.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/ReactInstance.java @@ -324,8 +324,8 @@ private class ReactJsExceptionHandlerImpl implements ReactJsExceptionHandler { } @Override - public void reportJsException(ParsedError error) { - JavaOnlyMap data = StackTraceHelper.convertParsedError(error); + public void reportJsException(ProcessedError error) { + JavaOnlyMap data = StackTraceHelper.convertProcessedError(error); try { NativeExceptionsManagerSpec exceptionsManager = diff --git a/packages/react-native/ReactAndroid/src/main/jni/react/runtime/jni/JReactExceptionManager.cpp b/packages/react-native/ReactAndroid/src/main/jni/react/runtime/jni/JReactExceptionManager.cpp index e0ac376122bd9d..3d61ab537288ec 100644 --- a/packages/react-native/ReactAndroid/src/main/jni/react/runtime/jni/JReactExceptionManager.cpp +++ b/packages/react-native/ReactAndroid/src/main/jni/react/runtime/jni/JReactExceptionManager.cpp @@ -16,20 +16,20 @@ namespace facebook::react { namespace { -class ParsedError : public facebook::jni::JavaClass { +class ProcessedError : public facebook::jni::JavaClass { public: static auto constexpr kJavaDescriptor = - "Lcom/facebook/react/interfaces/exceptionmanager/ReactJsExceptionHandler$ParsedError;"; + "Lcom/facebook/react/interfaces/exceptionmanager/ReactJsExceptionHandler$ProcessedError;"; }; -class ParsedStackFrameImpl - : public facebook::jni::JavaClass { +class ProcessedErrorStackFrameImpl + : public facebook::jni::JavaClass { public: static auto constexpr kJavaDescriptor = - "Lcom/facebook/react/interfaces/exceptionmanager/ReactJsExceptionHandler$ParsedStackFrameImpl;"; + "Lcom/facebook/react/interfaces/exceptionmanager/ReactJsExceptionHandler$ProcessedErrorStackFrameImpl;"; - static facebook::jni::local_ref create( - const JsErrorHandler::ParsedError::StackFrame& frame) { + static facebook::jni::local_ref create( + const JsErrorHandler::ProcessedError::StackFrame& frame) { return newInstance( frame.file ? jni::make_jstring(*frame.file) : nullptr, frame.methodName, @@ -38,18 +38,19 @@ class ParsedStackFrameImpl } }; -class ParsedErrorImpl - : public facebook::jni::JavaClass { +class ProcessedErrorImpl + : public facebook::jni::JavaClass { public: static auto constexpr kJavaDescriptor = - "Lcom/facebook/react/interfaces/exceptionmanager/ReactJsExceptionHandler$ParsedErrorImpl;"; + "Lcom/facebook/react/interfaces/exceptionmanager/ReactJsExceptionHandler$ProcessedErrorImpl;"; - static facebook::jni::local_ref create( + static facebook::jni::local_ref create( jsi::Runtime& runtime, - const JsErrorHandler::ParsedError& error) { - auto stack = facebook::jni::JArrayList::create(); + const JsErrorHandler::ProcessedError& error) { + auto stack = + facebook::jni::JArrayList::create(); for (const auto& frame : error.stack) { - stack->add(ParsedStackFrameImpl::create(frame)); + stack->add(ProcessedErrorStackFrameImpl::create(frame)); } auto extraDataDynamic = @@ -75,12 +76,12 @@ class ParsedErrorImpl void JReactExceptionManager::reportJsException( jsi::Runtime& runtime, - const JsErrorHandler::ParsedError& error) { + const JsErrorHandler::ProcessedError& error) { static const auto method = - javaClassStatic()->getMethod)>( + javaClassStatic()->getMethod)>( "reportJsException"); if (self() != nullptr) { - method(self(), ParsedErrorImpl::create(runtime, error)); + method(self(), ProcessedErrorImpl::create(runtime, error)); } } diff --git a/packages/react-native/ReactAndroid/src/main/jni/react/runtime/jni/JReactExceptionManager.h b/packages/react-native/ReactAndroid/src/main/jni/react/runtime/jni/JReactExceptionManager.h index 078977a0e1e2ce..8ab06a236bf536 100644 --- a/packages/react-native/ReactAndroid/src/main/jni/react/runtime/jni/JReactExceptionManager.h +++ b/packages/react-native/ReactAndroid/src/main/jni/react/runtime/jni/JReactExceptionManager.h @@ -21,7 +21,7 @@ class JReactExceptionManager void reportJsException( jsi::Runtime& runtime, - const JsErrorHandler::ParsedError& error); + const JsErrorHandler::ProcessedError& error); }; } // namespace facebook::react diff --git a/packages/react-native/ReactAndroid/src/main/jni/react/runtime/jni/JReactInstance.cpp b/packages/react-native/ReactAndroid/src/main/jni/react/runtime/jni/JReactInstance.cpp index e6cd6614e3e3e1..7a0edf60c8ba4b 100644 --- a/packages/react-native/ReactAndroid/src/main/jni/react/runtime/jni/JReactInstance.cpp +++ b/packages/react-native/ReactAndroid/src/main/jni/react/runtime/jni/JReactInstance.cpp @@ -53,7 +53,7 @@ JReactInstance::JReactInstance( auto onJsError = [weakJReactExceptionManager = jni::make_weak(jReactExceptionManager)]( jsi::Runtime& runtime, - const JsErrorHandler::ParsedError& error) mutable noexcept { + const JsErrorHandler::ProcessedError& error) mutable noexcept { if (auto jReactExceptionManager = weakJReactExceptionManager.lockLocal()) { jReactExceptionManager->reportJsException(runtime, error); diff --git a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/devsupport/StackTraceHelperTest.kt b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/devsupport/StackTraceHelperTest.kt index 655c4961fb9239..c3ab6a2ea8f775 100644 --- a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/devsupport/StackTraceHelperTest.kt +++ b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/devsupport/StackTraceHelperTest.kt @@ -65,10 +65,10 @@ class StackTraceHelperTest { } @Test - fun testConvertParsedError() { - val error = getParsedErrorTestData() + fun testConvertProcessedError() { + val error = getProcessedErrorTestData() - val data = StackTraceHelper.convertParsedError(error) + val data = StackTraceHelper.convertProcessedError(error) assertThat(data.getString("message")).isEqualTo("error message") assertThat(data.getInt("id")).isEqualTo(123) assertThat(data.getBoolean("isFatal")).isEqualTo(true) @@ -96,9 +96,9 @@ class StackTraceHelperTest { assertThat(map.getDouble("column").toInt()).isEqualTo(columnNumber) } - private fun getParsedErrorTestData(): ParsedError { + private fun getProcessedErrorTestData(): ProcessedError { val frame1 = - object : ParsedError.StackFrame { + object : ProcessedError.StackFrame { override val file = "file1" override val methodName = "method1" override val lineNumber = 1 @@ -106,7 +106,7 @@ class StackTraceHelperTest { } val frame2 = - object : ParsedError.StackFrame { + object : ProcessedError.StackFrame { override val file = "file2" override val methodName = "method2" override val lineNumber = 2 @@ -115,7 +115,7 @@ class StackTraceHelperTest { val frames = listOf(frame1, frame2) - return object : ParsedError { + return object : ProcessedError { override val message = "error message" override val originalMessage = null override val name = null diff --git a/packages/react-native/ReactCommon/jserrorhandler/JsErrorHandler.cpp b/packages/react-native/ReactCommon/jserrorhandler/JsErrorHandler.cpp index 20c6b48c424a5b..752397f4ad6880 100644 --- a/packages/react-native/ReactCommon/jserrorhandler/JsErrorHandler.cpp +++ b/packages/react-native/ReactCommon/jserrorhandler/JsErrorHandler.cpp @@ -124,10 +124,10 @@ jsi::Value getBundleMetadata(jsi::Runtime& runtime, jsi::JSError& error) { namespace facebook::react { template <> -struct Bridging { +struct Bridging { static jsi::Value toJs( jsi::Runtime& runtime, - const JsErrorHandler::ParsedError::StackFrame& frame) { + const JsErrorHandler::ProcessedError::StackFrame& frame) { auto stackFrame = jsi::Object(runtime); auto file = bridging::toJs(runtime, frame.file, nullptr); auto lineNumber = bridging::toJs(runtime, frame.lineNumber, nullptr); @@ -142,10 +142,10 @@ struct Bridging { }; template <> -struct Bridging { +struct Bridging { static jsi::Value toJs( jsi::Runtime& runtime, - const JsErrorHandler::ParsedError& error) { + const JsErrorHandler::ProcessedError& error) { auto data = jsi::Object(runtime); data.setProperty(runtime, "message", error.message); data.setProperty( @@ -175,7 +175,7 @@ struct Bridging { std::ostream& operator<<( std::ostream& os, - const JsErrorHandler::ParsedError::StackFrame& frame) { + const JsErrorHandler::ProcessedError::StackFrame& frame) { auto file = frame.file ? quote(*frame.file) : "nil"; auto methodName = quote(frame.methodName); auto lineNumber = @@ -188,7 +188,7 @@ std::ostream& operator<<( } std::ostream& operator<<( std::ostream& os, - const JsErrorHandler::ParsedError& error) { + const JsErrorHandler::ProcessedError& error) { auto message = quote(error.message); auto originalMessage = error.originalMessage ? quote(*error.originalMessage) : "nil"; @@ -199,7 +199,7 @@ std::ostream& operator<<( auto isFatal = std::to_string(static_cast(error.isFatal)); auto extraData = "jsi::Object{ } "; - os << "ParsedError {\n" + os << "ProcessedError {\n" << " .message = " << message << "\n" << " .originalMessage = " << originalMessage << "\n" << " .name = " << name << "\n" @@ -329,7 +329,7 @@ void JsErrorHandler::handleErrorWithCppPipeline( auto id = nextExceptionId(); - ParsedError parsedError = { + ProcessedError processedError = { .message = _isRuntimeReady ? message : ("[runtime not ready]: " + message), .originalMessage = originalMessage, @@ -341,7 +341,7 @@ void JsErrorHandler::handleErrorWithCppPipeline( .extraData = std::move(extraData), }; - auto data = bridging::toJs(runtime, parsedError).asObject(runtime); + auto data = bridging::toJs(runtime, processedError).asObject(runtime); auto isComponentError = isTruthy(runtime, errorObj.getProperty(runtime, "isComponentError")); @@ -351,7 +351,7 @@ void JsErrorHandler::handleErrorWithCppPipeline( auto console = runtime.global().getPropertyAsObject(runtime, "console"); auto errorFn = console.getPropertyAsFunction(runtime, "error"); auto finalMessage = - jsi::String::createFromUtf8(runtime, parsedError.message); + jsi::String::createFromUtf8(runtime, processedError.message); errorFn.callWithThis(runtime, console, finalMessage); } @@ -397,7 +397,7 @@ void JsErrorHandler::handleErrorWithCppPipeline( _hasHandledFatalError = true; } - _onJsError(runtime, parsedError); + _onJsError(runtime, processedError); } } diff --git a/packages/react-native/ReactCommon/jserrorhandler/JsErrorHandler.h b/packages/react-native/ReactCommon/jserrorhandler/JsErrorHandler.h index 4e215a02731114..455dc215ac610c 100644 --- a/packages/react-native/ReactCommon/jserrorhandler/JsErrorHandler.h +++ b/packages/react-native/ReactCommon/jserrorhandler/JsErrorHandler.h @@ -15,7 +15,7 @@ namespace facebook::react { class JsErrorHandler { public: - struct ParsedError { + struct ProcessedError { struct StackFrame { std::optional file; std::string methodName; @@ -34,11 +34,13 @@ class JsErrorHandler { int id; bool isFatal; jsi::Object extraData; - friend std::ostream& operator<<(std::ostream& os, const ParsedError& error); + friend std::ostream& operator<<( + std::ostream& os, + const ProcessedError& error); }; using OnJsError = - std::function; + std::function; explicit JsErrorHandler(OnJsError onJsError); ~JsErrorHandler(); diff --git a/packages/react-native/ReactCommon/jserrorhandler/StackTraceParser.cpp b/packages/react-native/ReactCommon/jserrorhandler/StackTraceParser.cpp index a389609ed8f87d..0d3d9fbbfa1a77 100644 --- a/packages/react-native/ReactCommon/jserrorhandler/StackTraceParser.cpp +++ b/packages/react-native/ReactCommon/jserrorhandler/StackTraceParser.cpp @@ -37,12 +37,12 @@ std::optional toInt(std::string_view input) { return out; } -JsErrorHandler::ParsedError::StackFrame parseStackFrame( +JsErrorHandler::ProcessedError::StackFrame parseStackFrame( std::string_view file, std::string_view methodName, std::string_view lineStr, std::string_view columnStr) { - JsErrorHandler::ParsedError::StackFrame frame; + JsErrorHandler::ProcessedError::StackFrame frame; frame.file = file.empty() ? std::nullopt : std::optional(file); frame.methodName = !methodName.empty() ? methodName : UNKNOWN_FUNCTION; frame.lineNumber = !lineStr.empty() ? toInt(lineStr) : std::nullopt; @@ -51,7 +51,7 @@ JsErrorHandler::ParsedError::StackFrame parseStackFrame( return frame; } -std::optional parseChrome( +std::optional parseChrome( const std::string& line) { static const std::regex chromeRe( R"(^\s*at (.*?) ?\(((?:file|https?|blob|chrome-extension|native|eval|webpack||\/|[a-z]:\\|\\\\).*?)(?::(\d+))?(?::(\d+))?\)?\s*$)", @@ -84,7 +84,7 @@ std::optional parseChrome( return parseStackFrame(actualFile, methodName, lineStr, columnStr); } -std::optional parseWinjs( +std::optional parseWinjs( const std::string& line) { static const std::regex winjsRe( R"(^\s*at (?:((?:\[object object\])?.+) )?\(?((?:file|ms-appx|https?|webpack|blob):.*?):(\d+)(?::(\d+))?\)?\s*$)", @@ -100,7 +100,7 @@ std::optional parseWinjs( return parseStackFrame(file, methodName, lineStr, columnStr); } -std::optional parseGecko( +std::optional parseGecko( const std::string& line) { static const std::regex geckoRe( R"(^\s*(.*?)(?:\((.*?)\))?(?:^|@)((?:file|https?|blob|chrome|webpack|resource|\[native).*?|[^@]*bundle)(?::(\d+))?(?::(\d+))?\s*$)", @@ -129,7 +129,7 @@ std::optional parseGecko( return parseStackFrame(file, methodName, lineStr, columnStr); } -std::optional parseJSC( +std::optional parseJSC( const std::string& line) { static const std::regex javaScriptCoreRe( R"(^\s*(?:([^@]*)(?:\((.*?)\))?@)?(\S.*?):(\d+)(?::(\d+))?\s*$)", @@ -147,7 +147,7 @@ std::optional parseJSC( return parseStackFrame(file, methodName, lineStr, columnStr); } -std::optional parseNode( +std::optional parseNode( const std::string& line) { static const std::regex nodeRe( R"(^\s*at (?:((?:\[object object\])?[^\\/]+(?: \[as \S+\])?) )?\(?(.*?):(\d+)(?::(\d+))?\)?\s*$)", @@ -163,14 +163,14 @@ std::optional parseNode( return parseStackFrame(file, methodName, lineStr, columnStr); } -std::vector parseOthers( +std::vector parseOthers( const std::string& stackString) { - std::vector stack; + std::vector stack; std::istringstream iss(stackString); std::string line; while (std::getline(iss, line)) { - std::optional frame = + std::optional frame = parseChrome(line); if (!frame) { @@ -219,9 +219,9 @@ bool isInternalBytecodeSourceUrl(const std::string& sourceUrl) { return sourceUrl == "InternalBytecode.js"; } -std::vector convertHermesStack( +std::vector convertHermesStack( const std::vector& stack) { - std::vector frames; + std::vector frames; for (const auto& entry : stack) { if (entry.type != "FRAME") { continue; @@ -230,7 +230,7 @@ std::vector convertHermesStack( entry.location.type == "INTERNAL_BYTECODE") { continue; } - JsErrorHandler::ParsedError::StackFrame frame; + JsErrorHandler::ProcessedError::StackFrame frame; frame.methodName = entry.functionName; frame.file = entry.location.sourceUrl; frame.lineNumber = entry.location.line1Based; @@ -282,7 +282,7 @@ HermesStackEntry parseLine(const std::string& line) { return entry; } -std::vector parseHermes( +std::vector parseHermes( const std::string& stack) { static const std::regex RE_COMPONENT_NO_STACK(R"(^ {4}at .*?$)"); std::istringstream stream(stack); @@ -308,10 +308,10 @@ std::vector parseHermes( } } // namespace -std::vector StackTraceParser::parse( +std::vector StackTraceParser::parse( const bool isHermes, const std::string& stackString) { - std::vector stackFrames = + std::vector stackFrames = isHermes ? parseHermes(stackString) : parseOthers(stackString); return stackFrames; } diff --git a/packages/react-native/ReactCommon/jserrorhandler/StackTraceParser.h b/packages/react-native/ReactCommon/jserrorhandler/StackTraceParser.h index 0e401e52756df2..e69787ca0ab091 100644 --- a/packages/react-native/ReactCommon/jserrorhandler/StackTraceParser.h +++ b/packages/react-native/ReactCommon/jserrorhandler/StackTraceParser.h @@ -15,7 +15,7 @@ namespace facebook::react { class StackTraceParser { public: - static std::vector parse( + static std::vector parse( bool isHermes, const std::string& stackString); }; diff --git a/packages/react-native/ReactCommon/jserrorhandler/tests/StackTraceParserTest.cpp b/packages/react-native/ReactCommon/jserrorhandler/tests/StackTraceParserTest.cpp index 83737775a89056..437c7deee46df2 100644 --- a/packages/react-native/ReactCommon/jserrorhandler/tests/StackTraceParserTest.cpp +++ b/packages/react-native/ReactCommon/jserrorhandler/tests/StackTraceParserTest.cpp @@ -262,37 +262,37 @@ TEST(StackTraceParser, nodeWithSpaceInPath) { StackTraceParser::parse(false, CapturedExceptions["NODE_SPACE"]); EXPECT_EQ(actualStackFrames.size(), 9); - std::vector expectedStackFrames = { - {R"(C:\project files\spect\src\index.js)", "Spect.get", 161, 25}, - {R"(C:\project files\spect\src\index.js)", "Object.get", 43, 35}, - {R"(C:\project files\spect\src\index.js)", - "(anonymous function).then", - 165, - 32}, - {"internal/process/task_queues.js", - "process.runNextTicks [as _tickCallback]", - 52, - 4}, - {R"(C:\project files\spect\node_modules\esm\esm.js)", - "", - 1, - 34534}, - {R"(C:\project files\spect\node_modules\esm\esm.js)", - "", - 1, - 34175}, - {R"(C:\project files\spect\node_modules\esm\esm.js)", - "process.", - 1, - 34505}, - {R"(C:\project files\spect\node_modules\esm\esm.js)", - "Function.", - 1, - 296855}, - {R"(C:\project files\spect\node_modules\esm\esm.js)", - "Function.", - 1, - 296554}}; + std::vector expectedStackFrames = + {{R"(C:\project files\spect\src\index.js)", "Spect.get", 161, 25}, + {R"(C:\project files\spect\src\index.js)", "Object.get", 43, 35}, + {R"(C:\project files\spect\src\index.js)", + "(anonymous function).then", + 165, + 32}, + {"internal/process/task_queues.js", + "process.runNextTicks [as _tickCallback]", + 52, + 4}, + {R"(C:\project files\spect\node_modules\esm\esm.js)", + "", + 1, + 34534}, + {R"(C:\project files\spect\node_modules\esm\esm.js)", + "", + 1, + 34175}, + {R"(C:\project files\spect\node_modules\esm\esm.js)", + "process.", + 1, + 34505}, + {R"(C:\project files\spect\node_modules\esm\esm.js)", + "Function.", + 1, + 296855}, + {R"(C:\project files\spect\node_modules\esm\esm.js)", + "Function.", + 1, + 296554}}; for (auto i = 0; i < expectedStackFrames.size(); i++) { EXPECT_EQ(actualStackFrames[i].column, expectedStackFrames[i].column); @@ -309,7 +309,7 @@ TEST(StackTraceParser, javaScriptCore) { StackTraceParser::parse(false, CapturedExceptions["IOS_REACT_NATIVE_1"]); EXPECT_EQ(actualStackFrames.size(), 4); - std::vector expectedStackFrames = { + std::vector expectedStackFrames = { {"/home/test/project/App.js", "_exampleFunction", 125, 12}, {"/home/test/project/node_modules/dep/index.js", "_depRunCallbacks", @@ -339,18 +339,18 @@ TEST(StackTraceParser, errorInReactNative) { StackTraceParser::parse(false, CapturedExceptions["IOS_REACT_NATIVE_2"]); EXPECT_EQ(actualStackFrames.size(), 11); - std::vector expectedStackFrames = { - {"33.js", "s", 1, 530}, - {"1959.js", "b", 1, 1468}, - {"2932.js", "onSocketClose", 1, 726}, - {"81.js", "value", 1, 1504}, - {"102.js", "", 1, 2955}, - {"89.js", "value", 1, 1246}, - {"42.js", "value", 1, 3310}, - {"42.js", "", 1, 821}, - {"42.js", "value", 1, 2564}, - {"42.js", "value", 1, 793}, - {"[native code]", "value", std::nullopt, std::nullopt}}; + std::vector expectedStackFrames = + {{"33.js", "s", 1, 530}, + {"1959.js", "b", 1, 1468}, + {"2932.js", "onSocketClose", 1, 726}, + {"81.js", "value", 1, 1504}, + {"102.js", "", 1, 2955}, + {"89.js", "value", 1, 1246}, + {"42.js", "value", 1, 3310}, + {"42.js", "", 1, 821}, + {"42.js", "value", 1, 2564}, + {"42.js", "value", 1, 793}, + {"[native code]", "value", std::nullopt, std::nullopt}}; for (auto i = 0; i < expectedStackFrames.size(); i++) { EXPECT_EQ(actualStackFrames[i].column, expectedStackFrames[i].column); @@ -367,8 +367,8 @@ TEST(StackTraceParser, simpleJavaScriptCoreErrors) { StackTraceParser::parse(false, "global code@stack_traces/test:83:55"); EXPECT_EQ(actualStackFrames.size(), 1); - std::vector expectedStackFrames = { - {"stack_traces/test", "global code", 83, 54}}; + std::vector expectedStackFrames = + {{"stack_traces/test", "global code", 83, 54}}; for (auto i = 0; i < expectedStackFrames.size(); i++) { EXPECT_EQ(actualStackFrames[i].column, expectedStackFrames[i].column); @@ -385,11 +385,11 @@ TEST(StackTraceParser, safari6Error) { StackTraceParser::parse(false, CapturedExceptions["SAFARI_6"]); EXPECT_EQ(actualStackFrames.size(), 4); - std::vector expectedStackFrames = { - {"http://path/to/file.js", "", 48, std::nullopt}, - {"http://path/to/file.js", "dumpException3", 52, std::nullopt}, - {"http://path/to/file.js", "onclick", 82, std::nullopt}, - {"[native code]", "", std::nullopt, std::nullopt}}; + std::vector expectedStackFrames = + {{"http://path/to/file.js", "", 48, std::nullopt}, + {"http://path/to/file.js", "dumpException3", 52, std::nullopt}, + {"http://path/to/file.js", "onclick", 82, std::nullopt}, + {"[native code]", "", std::nullopt, std::nullopt}}; for (auto i = 0; i < expectedStackFrames.size(); i++) { EXPECT_EQ(actualStackFrames[i].column, expectedStackFrames[i].column); @@ -406,10 +406,10 @@ TEST(StackTraceParser, safari7Error) { StackTraceParser::parse(false, CapturedExceptions["SAFARI_7"]); EXPECT_EQ(actualStackFrames.size(), 3); - std::vector expectedStackFrames = { - {"http://path/to/file.js", "", 48, 21}, - {"http://path/to/file.js", "foo", 52, 14}, - {"http://path/to/file.js", "bar", 108, 106}}; + std::vector expectedStackFrames = + {{"http://path/to/file.js", "", 48, 21}, + {"http://path/to/file.js", "foo", 52, 14}, + {"http://path/to/file.js", "bar", 108, 106}}; for (auto i = 0; i < expectedStackFrames.size(); i++) { EXPECT_EQ(actualStackFrames[i].column, expectedStackFrames[i].column); @@ -426,10 +426,10 @@ TEST(StackTraceParser, safari8Error) { StackTraceParser::parse(false, CapturedExceptions["SAFARI_8"]); EXPECT_EQ(actualStackFrames.size(), 3); - std::vector expectedStackFrames = { - {"http://path/to/file.js", "", 47, 21}, - {"http://path/to/file.js", "foo", 52, 14}, - {"http://path/to/file.js", "bar", 108, 22}}; + std::vector expectedStackFrames = + {{"http://path/to/file.js", "", 47, 21}, + {"http://path/to/file.js", "foo", 52, 14}, + {"http://path/to/file.js", "bar", 108, 22}}; for (auto i = 0; i < expectedStackFrames.size(); i++) { EXPECT_EQ(actualStackFrames[i].column, expectedStackFrames[i].column); @@ -446,10 +446,10 @@ TEST(StackTraceParser, safari8EvalError) { StackTraceParser::parse(false, CapturedExceptions["SAFARI_8_EVAL"]); EXPECT_EQ(actualStackFrames.size(), 3); - std::vector expectedStackFrames = { - {"[native code]", "eval", std::nullopt, std::nullopt}, - {"http://path/to/file.js", "foo", 58, 20}, - {"http://path/to/file.js", "bar", 109, 90}}; + std::vector expectedStackFrames = + {{"[native code]", "eval", std::nullopt, std::nullopt}, + {"http://path/to/file.js", "foo", 58, 20}, + {"http://path/to/file.js", "bar", 109, 90}}; for (auto i = 0; i < expectedStackFrames.size(); i++) { EXPECT_EQ(actualStackFrames[i].column, expectedStackFrames[i].column); @@ -466,17 +466,23 @@ TEST(StackTraceParser, firefox3Error) { StackTraceParser::parse(false, CapturedExceptions["FIREFOX_3"]); EXPECT_EQ(actualStackFrames.size(), 7); - std::vector expectedStackFrames = { - {"http://127.0.0.1:8000/js/stacktrace.js", "", 44, std::nullopt}, - {"http://127.0.0.1:8000/js/stacktrace.js", "", 31, std::nullopt}, - {"http://127.0.0.1:8000/js/stacktrace.js", - "printStackTrace", - 18, - std::nullopt}, - {"http://127.0.0.1:8000/js/file.js", "bar", 13, std::nullopt}, - {"http://127.0.0.1:8000/js/file.js", "bar", 16, std::nullopt}, - {"http://127.0.0.1:8000/js/file.js", "foo", 20, std::nullopt}, - {"http://127.0.0.1:8000/js/file.js", "", 24, std::nullopt}}; + std::vector expectedStackFrames = + {{"http://127.0.0.1:8000/js/stacktrace.js", + "", + 44, + std::nullopt}, + {"http://127.0.0.1:8000/js/stacktrace.js", + "", + 31, + std::nullopt}, + {"http://127.0.0.1:8000/js/stacktrace.js", + "printStackTrace", + 18, + std::nullopt}, + {"http://127.0.0.1:8000/js/file.js", "bar", 13, std::nullopt}, + {"http://127.0.0.1:8000/js/file.js", "bar", 16, std::nullopt}, + {"http://127.0.0.1:8000/js/file.js", "foo", 20, std::nullopt}, + {"http://127.0.0.1:8000/js/file.js", "", 24, std::nullopt}}; for (auto i = 0; i < expectedStackFrames.size(); i++) { EXPECT_EQ(actualStackFrames[i].column, expectedStackFrames[i].column); @@ -493,14 +499,14 @@ TEST(StackTraceParser, firefox7Error) { StackTraceParser::parse(false, CapturedExceptions["FIREFOX_7"]); EXPECT_EQ(actualStackFrames.size(), 7); - std::vector expectedStackFrames = { - {"file:///G:/js/stacktrace.js", "", 44, std::nullopt}, - {"file:///G:/js/stacktrace.js", "", 31, std::nullopt}, - {"file:///G:/js/stacktrace.js", "printStackTrace", 18, std::nullopt}, - {"file:///G:/js/file.js", "bar", 13, std::nullopt}, - {"file:///G:/js/file.js", "bar", 16, std::nullopt}, - {"file:///G:/js/file.js", "foo", 20, std::nullopt}, - {"file:///G:/js/file.js", "", 24, std::nullopt}}; + std::vector expectedStackFrames = + {{"file:///G:/js/stacktrace.js", "", 44, std::nullopt}, + {"file:///G:/js/stacktrace.js", "", 31, std::nullopt}, + {"file:///G:/js/stacktrace.js", "printStackTrace", 18, std::nullopt}, + {"file:///G:/js/file.js", "bar", 13, std::nullopt}, + {"file:///G:/js/file.js", "bar", 16, std::nullopt}, + {"file:///G:/js/file.js", "foo", 20, std::nullopt}, + {"file:///G:/js/file.js", "", 24, std::nullopt}}; for (auto i = 0; i < expectedStackFrames.size(); i++) { EXPECT_EQ(actualStackFrames[i].column, expectedStackFrames[i].column); @@ -517,10 +523,10 @@ TEST(StackTraceParser, firefox14Error) { StackTraceParser::parse(false, CapturedExceptions["FIREFOX_14"]); EXPECT_EQ(actualStackFrames.size(), 3); - std::vector expectedStackFrames = { - {"http://path/to/file.js", "", 48, std::nullopt}, - {"http://path/to/file.js", "dumpException3", 52, std::nullopt}, - {"http://path/to/file.js", "onclick", 1, std::nullopt}}; + std::vector expectedStackFrames = + {{"http://path/to/file.js", "", 48, std::nullopt}, + {"http://path/to/file.js", "dumpException3", 52, std::nullopt}, + {"http://path/to/file.js", "onclick", 1, std::nullopt}}; for (auto i = 0; i < expectedStackFrames.size(); i++) { EXPECT_EQ(actualStackFrames[i].column, expectedStackFrames[i].column); @@ -537,10 +543,10 @@ TEST(StackTraceParser, firefox31Error) { StackTraceParser::parse(false, CapturedExceptions["FIREFOX_31"]); EXPECT_EQ(actualStackFrames.size(), 3); - std::vector expectedStackFrames = { - {"http://path/to/file.js", "foo", 41, 12}, - {"http://path/to/file.js", "bar", 1, 0}, - {"http://path/to/file.js", ".plugin/e.fn[c]/<", 1, 0}}; + std::vector expectedStackFrames = + {{"http://path/to/file.js", "foo", 41, 12}, + {"http://path/to/file.js", "bar", 1, 0}, + {"http://path/to/file.js", ".plugin/e.fn[c]/<", 1, 0}}; for (auto i = 0; i < expectedStackFrames.size(); i++) { EXPECT_EQ(actualStackFrames[i].column, expectedStackFrames[i].column); @@ -557,11 +563,11 @@ TEST(StackTraceParser, firefox44) { false, CapturedExceptions["FIREFOX_44_NS_EXCEPTION"]); EXPECT_EQ(actualStackFrames.size(), 4); - std::vector expectedStackFrames = { - {"http://path/to/file.js", "[2]", 23, 0}}; + std::vector expectedStackFrames = + {{"http://path/to/file.js", "[2]", 23, 0}}; for (auto i = 0; i < expectedStackFrames.size(); i++) { EXPECT_EQ(actualStackFrames[i].column, expectedStackFrames[i].column); @@ -578,8 +584,8 @@ TEST(StackTraceParser, chromeErrorWithNoLocation) { StackTraceParser::parse(false, "error\n at Array.forEach (native)"); EXPECT_EQ(actualStackFrames.size(), 1); - std::vector expectedStackFrames = { - {std::nullopt, "Array.forEach", std::nullopt, std::nullopt}}; + std::vector expectedStackFrames = + {{std::nullopt, "Array.forEach", std::nullopt, std::nullopt}}; for (auto i = 0; i < expectedStackFrames.size(); i++) { EXPECT_EQ(actualStackFrames[i].column, expectedStackFrames[i].column); @@ -596,11 +602,11 @@ TEST(StackTraceParser, chrome15Error) { StackTraceParser::parse(false, CapturedExceptions["CHROME_15"]); EXPECT_EQ(actualStackFrames.size(), 4); - std::vector expectedStackFrames = { - {"http://path/to/file.js", "bar", 13, 16}, - {"http://path/to/file.js", "bar", 16, 4}, - {"http://path/to/file.js", "foo", 20, 4}, - {"http://path/to/file.js", "", 24, 3}}; + std::vector expectedStackFrames = + {{"http://path/to/file.js", "bar", 13, 16}, + {"http://path/to/file.js", "bar", 16, 4}, + {"http://path/to/file.js", "foo", 20, 4}, + {"http://path/to/file.js", "", 24, 3}}; for (auto i = 0; i < expectedStackFrames.size(); i++) { EXPECT_EQ(actualStackFrames[i].column, expectedStackFrames[i].column); @@ -617,13 +623,13 @@ TEST(StackTraceParser, chrome36Error) { StackTraceParser::parse(false, CapturedExceptions["CHROME_36"]); EXPECT_EQ(actualStackFrames.size(), 3); - std::vector expectedStackFrames = { - {"http://localhost:8080/file.js", "dumpExceptionError", 41, 26}, - {"http://localhost:8080/file.js", "HTMLButtonElement.onclick", 107, 145}, - {"http://localhost:8080/file.js", - "I.e.fn.(anonymous function) [as index]", - 10, - 3650}}; + std::vector expectedStackFrames = + {{"http://localhost:8080/file.js", "dumpExceptionError", 41, 26}, + {"http://localhost:8080/file.js", "HTMLButtonElement.onclick", 107, 145}, + {"http://localhost:8080/file.js", + "I.e.fn.(anonymous function) [as index]", + 10, + 3650}}; for (auto i = 0; i < expectedStackFrames.size(); i++) { EXPECT_EQ(actualStackFrames[i].column, expectedStackFrames[i].column); @@ -640,8 +646,8 @@ TEST(StackTraceParser, chrome76Error) { StackTraceParser::parse(false, CapturedExceptions["CHROME_76"]); EXPECT_EQ(actualStackFrames.size(), 2); - std::vector expectedStackFrames = { - {"", "bar", 8, 8}, {"", "async foo", 2, 2}}; + std::vector expectedStackFrames = + {{"", "bar", 8, 8}, {"", "async foo", 2, 2}}; for (auto i = 0; i < expectedStackFrames.size(); i++) { EXPECT_EQ(actualStackFrames[i].column, expectedStackFrames[i].column); @@ -658,27 +664,27 @@ TEST(StackTraceParser, chromeErrorWithWebpackURLS) { StackTraceParser::parse(false, CapturedExceptions["CHROME_XX_WEBPACK"]); EXPECT_EQ(actualStackFrames.size(), 5); - std::vector expectedStackFrames = { - {"webpack:///./src/components/test/test.jsx?", - "TESTTESTTEST.eval", - 295, - 107}, - {"webpack:///./src/components/test/test.jsx?", - "TESTTESTTEST.render", - 272, - 31}, - {"webpack:///./~/react-transform-catch-errors/lib/index.js?", - "TESTTESTTEST.tryRender", - 34, - 30}, - {"webpack:///./~/react-proxy/modules/createPrototypeProxy.js?", - "TESTTESTTEST.proxiedMethod", - 44, - 29}, - {R"(C:\root\server\development\pages\index.js)", - "Module../pages/index.js", - 182, - 6}}; + std::vector expectedStackFrames = + {{"webpack:///./src/components/test/test.jsx?", + "TESTTESTTEST.eval", + 295, + 107}, + {"webpack:///./src/components/test/test.jsx?", + "TESTTESTTEST.render", + 272, + 31}, + {"webpack:///./~/react-transform-catch-errors/lib/index.js?", + "TESTTESTTEST.tryRender", + 34, + 30}, + {"webpack:///./~/react-proxy/modules/createPrototypeProxy.js?", + "TESTTESTTEST.proxiedMethod", + 44, + 29}, + {R"(C:\root\server\development\pages\index.js)", + "Module../pages/index.js", + 182, + 6}}; for (auto i = 0; i < expectedStackFrames.size(); i++) { EXPECT_EQ(actualStackFrames[i].column, expectedStackFrames[i].column); @@ -695,12 +701,12 @@ TEST(StackTraceParser, nestedEvalsFromChrome) { StackTraceParser::parse(false, CapturedExceptions["CHROME_48_EVAL"]); EXPECT_EQ(actualStackFrames.size(), 5); - std::vector expectedStackFrames = { - {"http://localhost:8080/file.js", "baz", 21, 16}, - {"http://localhost:8080/file.js", "foo", 21, 16}, - {"http://localhost:8080/file.js", "eval", 21, 16}, - {"http://localhost:8080/file.js", "Object.speak", 21, 16}, - {"http://localhost:8080/file.js", "", 31, 12}}; + std::vector expectedStackFrames = + {{"http://localhost:8080/file.js", "baz", 21, 16}, + {"http://localhost:8080/file.js", "foo", 21, 16}, + {"http://localhost:8080/file.js", "eval", 21, 16}, + {"http://localhost:8080/file.js", "Object.speak", 21, 16}, + {"http://localhost:8080/file.js", "", 31, 12}}; for (auto i = 0; i < expectedStackFrames.size(); i++) { EXPECT_EQ(actualStackFrames[i].column, expectedStackFrames[i].column); @@ -717,32 +723,32 @@ TEST(StackTraceParser, chromeErrorWithBlobURLs) { StackTraceParser::parse(false, CapturedExceptions["CHROME_48_BLOB"]); EXPECT_EQ(actualStackFrames.size(), 7); - std::vector expectedStackFrames = { - {std::nullopt, "Error", std::nullopt, std::nullopt}, - {"blob:http%3A//localhost%3A8080/abfc40e9-4742-44ed-9dcd-af8f99a29379", - "s", - 31, - 29145}, - {"blob:http%3A//localhost%3A8080/abfc40e9-4742-44ed-9dcd-af8f99a29379", - "Object.d [as add]", - 31, - 30038}, - {"blob:http%3A//localhost%3A8080/d4eefe0f-361a-4682-b217-76587d9f712a", - "", - 15, - 10977}, - {"blob:http%3A//localhost%3A8080/abfc40e9-4742-44ed-9dcd-af8f99a29379", - "", - 1, - 6910}, - {"blob:http%3A//localhost%3A8080/abfc40e9-4742-44ed-9dcd-af8f99a29379", - "n.fire", - 7, - 3018}, - {"blob:http%3A//localhost%3A8080/abfc40e9-4742-44ed-9dcd-af8f99a29379", - "n.handle", - 7, - 2862}}; + std::vector expectedStackFrames = + {{std::nullopt, "Error", std::nullopt, std::nullopt}, + {"blob:http%3A//localhost%3A8080/abfc40e9-4742-44ed-9dcd-af8f99a29379", + "s", + 31, + 29145}, + {"blob:http%3A//localhost%3A8080/abfc40e9-4742-44ed-9dcd-af8f99a29379", + "Object.d [as add]", + 31, + 30038}, + {"blob:http%3A//localhost%3A8080/d4eefe0f-361a-4682-b217-76587d9f712a", + "", + 15, + 10977}, + {"blob:http%3A//localhost%3A8080/abfc40e9-4742-44ed-9dcd-af8f99a29379", + "", + 1, + 6910}, + {"blob:http%3A//localhost%3A8080/abfc40e9-4742-44ed-9dcd-af8f99a29379", + "n.fire", + 7, + 3018}, + {"blob:http%3A//localhost%3A8080/abfc40e9-4742-44ed-9dcd-af8f99a29379", + "n.handle", + 7, + 2862}}; for (auto i = 0; i < expectedStackFrames.size(); i++) { EXPECT_EQ(actualStackFrames[i].column, expectedStackFrames[i].column); @@ -759,10 +765,10 @@ TEST(StackTraceParser, ie10Error) { StackTraceParser::parse(false, CapturedExceptions["IE_10"]); EXPECT_EQ(actualStackFrames.size(), 3); - std::vector expectedStackFrames = { - {"http://path/to/file.js", "Anonymous function", 48, 12}, - {"http://path/to/file.js", "foo", 46, 8}, - {"http://path/to/file.js", "bar", 82, 0}}; + std::vector expectedStackFrames = + {{"http://path/to/file.js", "Anonymous function", 48, 12}, + {"http://path/to/file.js", "foo", 46, 8}, + {"http://path/to/file.js", "bar", 82, 0}}; for (auto i = 0; i < expectedStackFrames.size(); i++) { EXPECT_EQ(actualStackFrames[i].column, expectedStackFrames[i].column); @@ -779,10 +785,10 @@ TEST(StackTraceParser, ie11Error) { StackTraceParser::parse(false, CapturedExceptions["IE_11"]); EXPECT_EQ(actualStackFrames.size(), 3); - std::vector expectedStackFrames = { - {"http://path/to/file.js", "Anonymous function", 47, 20}, - {"http://path/to/file.js", "foo", 45, 12}, - {"http://path/to/file.js", "bar", 108, 0}}; + std::vector expectedStackFrames = + {{"http://path/to/file.js", "Anonymous function", 47, 20}, + {"http://path/to/file.js", "foo", 45, 12}, + {"http://path/to/file.js", "bar", 108, 0}}; for (auto i = 0; i < expectedStackFrames.size(); i++) { EXPECT_EQ(actualStackFrames[i].column, expectedStackFrames[i].column); @@ -798,10 +804,10 @@ TEST(StackTraceParser, ie11EvalError) { auto actualStackFrames = StackTraceParser::parse(false, CapturedExceptions["IE_11_EVAL"]); EXPECT_EQ(actualStackFrames.size(), 3); - std::vector expectedStackFrames = { - {"eval code", "eval code", 1, 0}, - {"http://path/to/file.js", "foo", 58, 16}, - {"http://path/to/file.js", "bar", 109, 0}}; + std::vector expectedStackFrames = + {{"eval code", "eval code", 1, 0}, + {"http://path/to/file.js", "foo", 58, 16}, + {"http://path/to/file.js", "bar", 109, 0}}; for (auto i = 0; i < expectedStackFrames.size(); i++) { EXPECT_EQ(actualStackFrames[i].column, expectedStackFrames[i].column); EXPECT_EQ(actualStackFrames[i].file, expectedStackFrames[i].file); @@ -816,10 +822,10 @@ TEST(StackTraceParser, Opera25Error) { auto actualStackFrames = StackTraceParser::parse(false, CapturedExceptions["OPERA_25"]); EXPECT_EQ(actualStackFrames.size(), 3); - std::vector expectedStackFrames = { - {"http://path/to/file.js", "", 47, 21}, - {"http://path/to/file.js", "foo", 52, 14}, - {"http://path/to/file.js", "bar", 108, 167}}; + std::vector expectedStackFrames = + {{"http://path/to/file.js", "", 47, 21}, + {"http://path/to/file.js", "foo", 52, 14}, + {"http://path/to/file.js", "bar", 108, 167}}; for (auto i = 0; i < expectedStackFrames.size(); i++) { EXPECT_EQ(actualStackFrames[i].column, expectedStackFrames[i].column); EXPECT_EQ(actualStackFrames[i].file, expectedStackFrames[i].file); @@ -834,10 +840,10 @@ TEST(StackTraceParser, PhantomJS119Error) { auto actualStackFrames = StackTraceParser::parse(false, CapturedExceptions["PHANTOMJS_1_19"]); EXPECT_EQ(actualStackFrames.size(), 3); - std::vector expectedStackFrames = { - {"file:///path/to/file.js", "", 878, std::nullopt}, - {"http://path/to/file.js", "foo", 4283, std::nullopt}, - {"http://path/to/file.js", "", 4287, std::nullopt}}; + std::vector expectedStackFrames = + {{"file:///path/to/file.js", "", 878, std::nullopt}, + {"http://path/to/file.js", "foo", 4283, std::nullopt}, + {"http://path/to/file.js", "", 4287, std::nullopt}}; for (auto i = 0; i < expectedStackFrames.size(); i++) { EXPECT_EQ(actualStackFrames[i].column, expectedStackFrames[i].column); EXPECT_EQ(actualStackFrames[i].file, expectedStackFrames[i].file); @@ -852,8 +858,8 @@ TEST(StackTraceParser, FirefoxResourceUrlError) { auto actualStackFrames = StackTraceParser::parse( false, CapturedExceptions["FIREFOX_50_RESOURCE_URL"]); EXPECT_EQ(actualStackFrames.size(), 3); - std::vector expectedStackFrames = { - {"resource://path/data/content/bundle.js", "render", 5529, 15}}; + std::vector expectedStackFrames = + {{"resource://path/data/content/bundle.js", "render", 5529, 15}}; for (auto i = 0; i < expectedStackFrames.size(); i++) { EXPECT_EQ(actualStackFrames[i].column, expectedStackFrames[i].column); EXPECT_EQ(actualStackFrames[i].file, expectedStackFrames[i].file); @@ -868,12 +874,12 @@ TEST(StackTraceParser, FirefoxEvalUrlError) { auto actualStackFrames = StackTraceParser::parse(false, CapturedExceptions["FIREFOX_43_EVAL"]); EXPECT_EQ(actualStackFrames.size(), 5); - std::vector expectedStackFrames = { - {"http://localhost:8080/file.js", "baz", 26, std::nullopt}, - {"http://localhost:8080/file.js", "foo", 26, std::nullopt}, - {"http://localhost:8080/file.js", "", 26, std::nullopt}, - {"http://localhost:8080/file.js", "speak", 26, 16}, - {"http://localhost:8080/file.js", "", 33, 8}}; + std::vector expectedStackFrames = + {{"http://localhost:8080/file.js", "baz", 26, std::nullopt}, + {"http://localhost:8080/file.js", "foo", 26, std::nullopt}, + {"http://localhost:8080/file.js", "", 26, std::nullopt}, + {"http://localhost:8080/file.js", "speak", 26, 16}, + {"http://localhost:8080/file.js", "", 33, 8}}; for (auto i = 0; i < expectedStackFrames.size(); i++) { EXPECT_EQ(actualStackFrames[i].column, expectedStackFrames[i].column); EXPECT_EQ(actualStackFrames[i].file, expectedStackFrames[i].file); @@ -888,7 +894,7 @@ TEST(StackTraceParser, ReactNativeAndroidError) { auto actualStackFrames = StackTraceParser::parse( false, CapturedExceptions["ANDROID_REACT_NATIVE"]); EXPECT_EQ(actualStackFrames.size(), 8); - std::vector expectedStackFrames = { + std::vector expectedStackFrames = { {"/home/username/sample-workspace/sampleapp.collect.react/src/components/GpsMonitorScene.js", "render", 78, @@ -913,10 +919,10 @@ TEST(StackTraceParser, ReactNativeAndroidProdError) { auto actualStackFrames = StackTraceParser::parse( false, CapturedExceptions["ANDROID_REACT_NATIVE_PROD"]); EXPECT_EQ(actualStackFrames.size(), 37); - std::vector expectedStackFrames = { - {"index.android.bundle", "value", 12, 1916}, - {"index.android.bundle", "value", 29, 926}, - {"[native code]", "", std::nullopt, std::nullopt}}; + std::vector expectedStackFrames = + {{"index.android.bundle", "value", 12, 1916}, + {"index.android.bundle", "value", 29, 926}, + {"[native code]", "", std::nullopt, std::nullopt}}; EXPECT_EQ(actualStackFrames[0].column, expectedStackFrames[0].column); EXPECT_EQ(actualStackFrames[0].file, expectedStackFrames[0].file); EXPECT_EQ(actualStackFrames[0].lineNumber, expectedStackFrames[0].lineNumber); @@ -941,9 +947,9 @@ TEST(StackTraceParser, NodeJsAsyncErrorsVersion12) { auto actualStackFrames = StackTraceParser::parse(false, CapturedExceptions["NODE_12"]); EXPECT_EQ(actualStackFrames.size(), 2); - std::vector expectedStackFrames = { - {"/home/xyz/hack/asyncnode.js", "promiseMe", 11, 8}, - {"/home/xyz/hack/asyncnode.js", "async main", 15, 12}}; + std::vector expectedStackFrames = + {{"/home/xyz/hack/asyncnode.js", "promiseMe", 11, 8}, + {"/home/xyz/hack/asyncnode.js", "async main", 15, 12}}; for (size_t i = 0; i < expectedStackFrames.size(); i++) { EXPECT_EQ(actualStackFrames[i].column, expectedStackFrames[i].column); @@ -959,17 +965,17 @@ TEST(StackTraceParser, NodeJsErrorsWithAnonymousCalls) { auto actualStackFrames = StackTraceParser::parse(false, CapturedExceptions["NODE_ANONYM"]); EXPECT_EQ(actualStackFrames.size(), 9); - std::vector expectedStackFrames = { - {R"(C:\projects\spect\src\index.js)", "Spect.get", 161, 25}, - {R"(C:\projects\spect\src\index.js)", - "(anonymous function).then", - 165, - 32}, - {R"(C:\projects\spect\node_modules\esm\esm.js)", "", 1, 34534}, - {R"(C:\projects\spect\node_modules\esm\esm.js)", - "process.", - 1, - 34505}}; + std::vector expectedStackFrames = + {{R"(C:\projects\spect\src\index.js)", "Spect.get", 161, 25}, + {R"(C:\projects\spect\src\index.js)", + "(anonymous function).then", + 165, + 32}, + {R"(C:\projects\spect\node_modules\esm\esm.js)", "", 1, 34534}, + {R"(C:\projects\spect\node_modules\esm\esm.js)", + "process.", + 1, + 34505}}; // Check specific stack frames as per the JavaScript test EXPECT_EQ(actualStackFrames[0].column, expectedStackFrames[0].column); EXPECT_EQ(actualStackFrames[0].file, expectedStackFrames[0].file); @@ -996,9 +1002,9 @@ TEST(StackTraceParser, AnonymousSources) { auto actualStackFrames = StackTraceParser::parse(false, CapturedExceptions["ANONYMOUS_SOURCES"]); EXPECT_EQ(actualStackFrames.size(), 2); - std::vector expectedStackFrames = { - {"http://www.example.com/test.js", "new ", 2, 0}, - {"", "", 1, 1}}; + std::vector expectedStackFrames = + {{"http://www.example.com/test.js", "new ", 2, 0}, + {"", "", 1, 1}}; for (size_t i = 0; i < expectedStackFrames.size(); i++) { EXPECT_EQ(actualStackFrames[i].column, expectedStackFrames[i].column); @@ -1014,12 +1020,12 @@ TEST(StackTraceParser, NodeJsTest1) { auto actualStackFrames = StackTraceParser::parse(false, CapturedExceptions["NODE_JS_TEST_1"]); EXPECT_EQ(actualStackFrames.size(), 5); - std::vector expectedStackFrames = { - {"repl", "", 1, 1}, - {"repl.js", "REPLServer.self.eval", 110, 20}, - {"repl.js", "Interface.", 239, 11}, - {"events.js", "Interface.EventEmitter.emit", 95, 16}, - {"readline.js", "emitKey", 1095, 11}}; + std::vector expectedStackFrames = + {{"repl", "", 1, 1}, + {"repl.js", "REPLServer.self.eval", 110, 20}, + {"repl.js", "Interface.", 239, 11}, + {"events.js", "Interface.EventEmitter.emit", 95, 16}, + {"readline.js", "emitKey", 1095, 11}}; for (size_t i = 0; i < expectedStackFrames.size(); i++) { EXPECT_EQ(actualStackFrames[i].column, expectedStackFrames[i].column); EXPECT_EQ(actualStackFrames[i].file, expectedStackFrames[i].file); @@ -1034,9 +1040,9 @@ TEST(StackTraceParser, NodeJsTest2) { auto actualStackFrames = StackTraceParser::parse(false, CapturedExceptions["NODE_JS_TEST_2"]); EXPECT_EQ(actualStackFrames.size(), 2); - std::vector expectedStackFrames = { - {"repl", "null._onTimeout", 1, 24}, - {"timers.js", "Timer.listOnTimeout [as ontimeout]", 110, 14}}; + std::vector expectedStackFrames = + {{"repl", "null._onTimeout", 1, 24}, + {"timers.js", "Timer.listOnTimeout [as ontimeout]", 110, 14}}; for (size_t i = 0; i < expectedStackFrames.size(); i++) { EXPECT_EQ(actualStackFrames[i].column, expectedStackFrames[i].column); EXPECT_EQ(actualStackFrames[i].file, expectedStackFrames[i].file); @@ -1051,17 +1057,17 @@ TEST(StackTraceParser, IoJs) { auto actualStackFrames = StackTraceParser::parse(false, CapturedExceptions["IO_JS"]); EXPECT_EQ(actualStackFrames.size(), 10); - std::vector expectedStackFrames = { - {"repl", "", 1, 0}, - {"repl.js", "REPLServer.defaultEval", 154, 26}, - {"domain.js", "bound", 254, 13}, - {"domain.js", "REPLServer.runBound [as eval]", 267, 11}, - {"repl.js", "REPLServer.", 308, 11}, - {"events.js", "emitOne", 77, 12}, - {"events.js", "REPLServer.emit", 169, 6}, - {"readline.js", "REPLServer.Interface._onLine", 210, 9}, - {"readline.js", "REPLServer.Interface._line", 549, 7}, - {"readline.js", "REPLServer.Interface._ttyWrite", 826, 13}}; + std::vector expectedStackFrames = + {{"repl", "", 1, 0}, + {"repl.js", "REPLServer.defaultEval", 154, 26}, + {"domain.js", "bound", 254, 13}, + {"domain.js", "REPLServer.runBound [as eval]", 267, 11}, + {"repl.js", "REPLServer.", 308, 11}, + {"events.js", "emitOne", 77, 12}, + {"events.js", "REPLServer.emit", 169, 6}, + {"readline.js", "REPLServer.Interface._onLine", 210, 9}, + {"readline.js", "REPLServer.Interface._line", 549, 7}, + {"readline.js", "REPLServer.Interface._ttyWrite", 826, 13}}; for (size_t i = 0; i < expectedStackFrames.size(); i++) { EXPECT_EQ(actualStackFrames[i].column, expectedStackFrames[i].column); EXPECT_EQ(actualStackFrames[i].file, expectedStackFrames[i].file); @@ -1083,8 +1089,8 @@ TEST(StackTraceParser, hermesBytecodeLocation) { " at foo$bar (address at /js/foo.hbc:10:1234)"); EXPECT_EQ(actualStackFrames.size(), 2); - std::vector expectedStackFrames = { - {"unknown", "global", 1, 9}, {"/js/foo.hbc", "foo$bar", 10, 1234}}; + std::vector expectedStackFrames = + {{"unknown", "global", 1, 9}, {"/js/foo.hbc", "foo$bar", 10, 1234}}; for (size_t i = 0; i < expectedStackFrames.size(); i++) { EXPECT_EQ(actualStackFrames[i].column, expectedStackFrames[i].column); @@ -1103,8 +1109,8 @@ TEST(StackTraceParser, internalBytecodeLocation) { " at internal (address at InternalBytecode.js:1:9)\n" " at notInternal (address at /js/InternalBytecode.js:10:1234)"); EXPECT_EQ(actualStackFrames.size(), 1); - std::vector expectedStackFrames = { - {"/js/InternalBytecode.js", "notInternal", 10, 1234}}; + std::vector expectedStackFrames = + {{"/js/InternalBytecode.js", "notInternal", 10, 1234}}; for (size_t i = 0; i < expectedStackFrames.size(); i++) { EXPECT_EQ(actualStackFrames[i].column, expectedStackFrames[i].column); @@ -1123,8 +1129,8 @@ TEST(StackTraceParser, sourceLocation) { " at global (unknown:1:9)\n" " at foo$bar (/js/foo.js:10:1234)"); EXPECT_EQ(actualStackFrames.size(), 2); - std::vector expectedStackFrames = { - {"unknown", "global", 1, 8}, {"/js/foo.js", "foo$bar", 10, 1233}}; + std::vector expectedStackFrames = + {{"unknown", "global", 1, 8}, {"/js/foo.js", "foo$bar", 10, 1233}}; for (size_t i = 0; i < expectedStackFrames.size(); i++) { EXPECT_EQ(actualStackFrames[i].column, expectedStackFrames[i].column); @@ -1143,8 +1149,8 @@ TEST(StackTraceParser, tolerateEmptyFilename) { " at global (unknown:1:9)\n" " at foo$bar (:10:1234)"); EXPECT_EQ(actualStackFrames.size(), 2); - std::vector expectedStackFrames = { - {"unknown", "global", 1, 8}, {"", "foo$bar", 10, 1233}}; + std::vector expectedStackFrames = + {{"unknown", "global", 1, 8}, {"", "foo$bar", 10, 1233}}; for (size_t i = 0; i < expectedStackFrames.size(); i++) { EXPECT_EQ(actualStackFrames[i].column, expectedStackFrames[i].column); EXPECT_EQ(actualStackFrames[i].file, expectedStackFrames[i].file); @@ -1163,8 +1169,8 @@ TEST(StackTraceParser, skippedFrames) { " ... skipping 50 frames\n" " at foo$bar (/js/foo.js:10:1234)"); EXPECT_EQ(actualStackFrames.size(), 2); - std::vector expectedStackFrames = { - {"unknown", "global", 1, 8}, {"/js/foo.js", "foo$bar", 10, 1233}}; + std::vector expectedStackFrames = + {{"unknown", "global", 1, 8}, {"/js/foo.js", "foo$bar", 10, 1233}}; for (size_t i = 0; i < expectedStackFrames.size(); i++) { EXPECT_EQ(actualStackFrames[i].column, expectedStackFrames[i].column); EXPECT_EQ(actualStackFrames[i].file, expectedStackFrames[i].file); @@ -1183,8 +1189,8 @@ TEST(StackTraceParser, handleNonStandardLines) { " but the real stack trace follows below.\n" " at foo$bar (/js/foo.js:10:1234)"); EXPECT_EQ(actualStackFrames.size(), 1); - std::vector expectedStackFrames = { - {"/js/foo.js", "foo$bar", 10, 1233}}; + std::vector expectedStackFrames = + {{"/js/foo.js", "foo$bar", 10, 1233}}; for (size_t i = 0; i < expectedStackFrames.size(); i++) { EXPECT_EQ(actualStackFrames[i].column, expectedStackFrames[i].column); EXPECT_EQ(actualStackFrames[i].file, expectedStackFrames[i].file); diff --git a/packages/react-native/ReactCommon/jsinspector-modern/tests/ReactInstanceIntegrationTest.cpp b/packages/react-native/ReactCommon/jsinspector-modern/tests/ReactInstanceIntegrationTest.cpp index e26cd9e72f4f3e..e658a1c65056ce 100644 --- a/packages/react-native/ReactCommon/jsinspector-modern/tests/ReactInstanceIntegrationTest.cpp +++ b/packages/react-native/ReactCommon/jsinspector-modern/tests/ReactInstanceIntegrationTest.cpp @@ -35,7 +35,7 @@ void ReactInstanceIntegrationTest::SetUp() { std::make_shared(std::move(mockRegistry)); auto onJsError = [](jsi::Runtime& /*runtime*/, - const JsErrorHandler::ParsedError& error) noexcept { + const JsErrorHandler::ProcessedError& error) noexcept { LOG(INFO) << "[jsErrorHandlingFunc called]"; LOG(INFO) << error << std::endl; }; diff --git a/packages/react-native/ReactCommon/react/runtime/platform/ios/ReactCommon/RCTInstance.mm b/packages/react-native/ReactCommon/react/runtime/platform/ios/ReactCommon/RCTInstance.mm index e3398c9aaa69d2..10de78fd5d95e7 100644 --- a/packages/react-native/ReactCommon/react/runtime/platform/ios/ReactCommon/RCTInstance.mm +++ b/packages/react-native/ReactCommon/react/runtime/platform/ios/ReactCommon/RCTInstance.mm @@ -232,7 +232,7 @@ - (void)_start objCTimerRegistryRawPtr->setTimerManager(timerManager); __weak __typeof(self) weakSelf = self; - auto onJsError = [=](jsi::Runtime &runtime, const JsErrorHandler::ParsedError &error) { + auto onJsError = [=](jsi::Runtime &runtime, const JsErrorHandler::ProcessedError &error) { [weakSelf _handleJSError:error withRuntime:runtime]; }; @@ -477,7 +477,7 @@ - (void)_loadScriptFromSource:(RCTSource *)source }); } -- (void)_handleJSError:(const JsErrorHandler::ParsedError &)error withRuntime:(jsi::Runtime &)runtime +- (void)_handleJSError:(const JsErrorHandler::ProcessedError &)error withRuntime:(jsi::Runtime &)runtime { NSMutableDictionary *errorData = [NSMutableDictionary new]; errorData[@"message"] = @(error.message.c_str()); @@ -492,7 +492,7 @@ - (void)_handleJSError:(const JsErrorHandler::ParsedError &)error withRuntime:(j } NSMutableArray *> *stack = [NSMutableArray new]; - for (const JsErrorHandler::ParsedError::StackFrame &frame : error.stack) { + for (const JsErrorHandler::ProcessedError::StackFrame &frame : error.stack) { NSMutableDictionary *stackFrame = [NSMutableDictionary new]; if (frame.file) { stackFrame[@"file"] = @(frame.file->c_str()); diff --git a/packages/react-native/ReactCommon/react/runtime/tests/cxx/ReactInstanceTest.cpp b/packages/react-native/ReactCommon/react/runtime/tests/cxx/ReactInstanceTest.cpp index 7fb0c662c23d62..6e93d7a2b8aa87 100644 --- a/packages/react-native/ReactCommon/react/runtime/tests/cxx/ReactInstanceTest.cpp +++ b/packages/react-native/ReactCommon/react/runtime/tests/cxx/ReactInstanceTest.cpp @@ -124,10 +124,11 @@ class ReactInstanceTest : public ::testing::Test { auto mockRegistry = std::make_unique(); mockRegistry_ = mockRegistry.get(); timerManager_ = std::make_shared(std::move(mockRegistry)); - auto onJsError = [](jsi::Runtime& /*runtime*/, - const JsErrorHandler::ParsedError& /*error*/) noexcept { - // Do nothing - }; + auto onJsError = + [](jsi::Runtime& /*runtime*/, + const JsErrorHandler::ProcessedError& /*error*/) noexcept { + // Do nothing + }; instance_ = std::make_unique( std::move(runtime),