Skip to content

Commit

Permalink
Merge pull request #10271 from garymathews/TIMOB-26317
Browse files Browse the repository at this point in the history
[TIMOB-26317] Android: Improve java stack trace handling
  • Loading branch information
garymathews committed Aug 31, 2018
2 parents fb0202f + 92dabda commit 74bb07e
Showing 1 changed file with 19 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,30 @@ public static String getError(KrollDict error)
}
// sometimes the stacktrace can include the error
// don't re-print the error if that is the case
if (!jsStack.contains("Error:")) {
output += message + "\n";
}
if (jsStack != null) {
if (!jsStack.contains("Error:")) {
output += message + "\n";
}
output += jsStack + "\n";
}
if (javaStack != null) {
output += javaStack;

// no java stack, attempt to obtain last ten stack entries
// omitting our error handling entries
} else {
StackTraceElement[] trace = new Error().getStackTrace();
int startIndex = 0;
for (StackTraceElement e : trace) {
startIndex++;
if (e.getMethodName().equals("dispatchException")) {
break;
}
}
int endIndex = startIndex + 10;
for (int i = startIndex; trace.length >= endIndex && i < endIndex; i++) {
output += "\n " + trace[i].toString();
}
}

return output;
Expand Down

0 comments on commit 74bb07e

Please sign in to comment.