mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-11 11:29:03 +08:00
Gracefully handle any unrecognized stack frame format
Reviewed By: javache Differential Revision: D5736692 fbshipit-source-id: e90dc38fa203ae65ac839f37940e96f23b35c330
This commit is contained in:
committed by
Facebook Github Bot
parent
259161f872
commit
93993799eb
@@ -9,18 +9,15 @@
|
||||
|
||||
package com.facebook.react.devsupport;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import com.facebook.react.bridge.ReadableArray;
|
||||
import com.facebook.react.bridge.ReadableMap;
|
||||
import com.facebook.react.bridge.ReadableType;
|
||||
import com.facebook.react.common.MapBuilder;
|
||||
import com.facebook.react.devsupport.interfaces.StackFrame;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import javax.annotation.Nullable;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
@@ -180,19 +177,15 @@ public class StackTraceHelper {
|
||||
String[] stackTrace = stack.split("\n");
|
||||
StackFrame[] result = new StackFrame[stackTrace.length];
|
||||
for (int i = 0; i < stackTrace.length; ++i) {
|
||||
if (stackTrace[i].equals("[native code]")) {
|
||||
result[i] = new StackFrameImpl(null, stackTrace[i], -1, -1);
|
||||
} else {
|
||||
Matcher matcher = STACK_FRAME_PATTERN.matcher(stackTrace[i]);
|
||||
if (!matcher.find()) {
|
||||
throw new IllegalArgumentException(
|
||||
"Unexpected stack frame format: " + stackTrace[i]);
|
||||
}
|
||||
Matcher matcher = STACK_FRAME_PATTERN.matcher(stackTrace[i]);
|
||||
if (matcher.find()) {
|
||||
result[i] = new StackFrameImpl(
|
||||
matcher.group(2),
|
||||
matcher.group(1) == null ? "(unknown)" : matcher.group(1),
|
||||
Integer.parseInt(matcher.group(3)),
|
||||
Integer.parseInt(matcher.group(4)));
|
||||
} else {
|
||||
result[i] = new StackFrameImpl(null, stackTrace[i], -1, -1);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
||||
Reference in New Issue
Block a user