Fix crash when dumping crash report for an exception that has a null cause (#7308)

This commit is contained in:
ichttt 2020-09-08 21:00:55 +02:00 committed by GitHub
parent 84fe2cbcc4
commit 051416b823
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -84,12 +84,13 @@ public class CrashReportExtender
category.addDetail("Caused by "+(depth++), cause +"\n\t\t"+ Arrays.stream(cause.getStackTrace()).map(Objects::toString).collect(Collectors.joining("\n\t\t"))); category.addDetail("Caused by "+(depth++), cause +"\n\t\t"+ Arrays.stream(cause.getStackTrace()).map(Objects::toString).collect(Collectors.joining("\n\t\t")));
cause = cause.getCause(); cause = cause.getCause();
} }
category.applyStackTrace(cause); if (cause != null)
category.addDetail("Mod File", modInfo.map(IModInfo::getOwningFile).map(t->((ModFileInfo)t).getFile().getFileName()).orElse("NO FILE INFO")); category.applyStackTrace(cause);
category.addDetail("Failure message", mle.getCleanMessage().replace("\n", "\n\t\t")); category.addDetail("Mod File", () -> modInfo.map(IModInfo::getOwningFile).map(t->((ModFileInfo)t).getFile().getFileName()).orElse("NO FILE INFO"));
category.addDetail("Failure message", () -> mle.getCleanMessage().replace("\n", "\n\t\t"));
category.addDetail("Exception message", Objects.toString(cause, "MISSING EXCEPTION MESSAGE")); category.addDetail("Exception message", Objects.toString(cause, "MISSING EXCEPTION MESSAGE"));
category.addDetail("Mod Version", modInfo.map(IModInfo::getVersion).map(Object::toString).orElse("NO MOD INFO AVAILABLE")); category.addDetail("Mod Version", () -> modInfo.map(IModInfo::getVersion).map(Object::toString).orElse("NO MOD INFO AVAILABLE"));
category.addDetail("Mod Issue URL", modInfo.map(IModInfo::getOwningFile).map(ModFileInfo.class::cast).flatMap(mfi->mfi.getConfigElement("issueTrackerURL")).orElse("NOT PROVIDED")); category.addDetail("Mod Issue URL", () -> modInfo.map(IModInfo::getOwningFile).map(ModFileInfo.class::cast).flatMap(mfi->mfi.getConfigElement("issueTrackerURL")).orElse("NOT PROVIDED").toString());
}); });
final File file1 = new File(topLevelDir, "crash-reports"); final File file1 = new File(topLevelDir, "crash-reports");
final File file2 = new File(file1, "crash-" + (new SimpleDateFormat("yyyy-MM-dd_HH.mm.ss")).format(new Date()) + "-fml.txt"); final File file2 = new File(file1, "crash-" + (new SimpleDateFormat("yyyy-MM-dd_HH.mm.ss")).format(new Date()) + "-fml.txt");