feat(crash): read crash report from raw log as fallback.

This commit is contained in:
huanghongxun
2021-10-20 01:13:52 +08:00
parent de421f93b5
commit 6707ce1ed9
8 changed files with 187 additions and 27 deletions

View File

@@ -155,6 +155,13 @@ public final class CrashReportAnalyzer {
}
}
public static String extractCrashReport(String rawLog) {
int begin = rawLog.lastIndexOf("---- Minecraft Crash Report ----");
int end = rawLog.lastIndexOf("#@!@# Game crashed! Crash report saved to");
if (begin == -1 || end == -1 || begin >= end) return null;
return rawLog.substring(begin, end);
}
private static final Pattern CRASH_REPORT_STACK_TRACE_PATTERN = Pattern.compile("Description: (.*?)[\\n\\r]+(?<stacktrace>[\\w\\W\\n\\r]+)A detailed walkthrough of the error");
private static final Pattern STACK_TRACE_LINE_PATTERN = Pattern.compile("at (?<method>.*?)\\((.*?)\\)");
private static final Set<String> PACKAGE_KEYWORD_BLACK_LIST = new HashSet<>(Arrays.asList(
@@ -171,7 +178,7 @@ public final class CrashReportAnalyzer {
"fabricmc", "loader", "game", "knot", "launch", "mixin" // fabric
));
public static Set<String> findKeywordsFromCrashReport(String crashReport) throws IOException, InvalidPathException {
public static Set<String> findKeywordsFromCrashReport(String crashReport) {
Matcher matcher = CRASH_REPORT_STACK_TRACE_PATTERN.matcher(crashReport);
Set<String> result = new HashSet<>();
if (matcher.find()) {