Tweak crash report dump to visit all the causes up to the top.
Signed-off-by: cpw <cpw+github@weeksfamily.ca>
This commit is contained in:
parent
4ff0d246ce
commit
84fe2cbcc4
1 changed files with 14 additions and 4 deletions
|
@ -24,13 +24,16 @@ import net.minecraft.crash.CrashReport;
|
||||||
import net.minecraft.crash.CrashReportCategory;
|
import net.minecraft.crash.CrashReportCategory;
|
||||||
import net.minecraftforge.fml.common.ICrashCallable;
|
import net.minecraftforge.fml.common.ICrashCallable;
|
||||||
import net.minecraftforge.fml.loading.moddiscovery.ModFileInfo;
|
import net.minecraftforge.fml.loading.moddiscovery.ModFileInfo;
|
||||||
|
import net.minecraftforge.forgespi.language.IModFileInfo;
|
||||||
import net.minecraftforge.forgespi.language.IModInfo;
|
import net.minecraftforge.forgespi.language.IModInfo;
|
||||||
|
import net.minecraftforge.forgespi.locating.IModFile;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class CrashReportExtender
|
public class CrashReportExtender
|
||||||
{
|
{
|
||||||
|
@ -74,10 +77,17 @@ public class CrashReportExtender
|
||||||
final CrashReport crashReport = CrashReport.makeCrashReport(new Exception("Mod Loading has failed"), "Mod loading error has occurred");
|
final CrashReport crashReport = CrashReport.makeCrashReport(new Exception("Mod Loading has failed"), "Mod loading error has occurred");
|
||||||
error.getErrors().forEach(mle -> {
|
error.getErrors().forEach(mle -> {
|
||||||
final Optional<IModInfo> modInfo = Optional.ofNullable(mle.getModInfo());
|
final Optional<IModInfo> modInfo = Optional.ofNullable(mle.getModInfo());
|
||||||
final CrashReportCategory category = crashReport.makeCategory(modInfo.map(IModInfo::getModId).orElse("NO MOD INFO AVAILABLE"));
|
final CrashReportCategory category = crashReport.makeCategory(modInfo.map(iModInfo -> "MOD "+iModInfo.getModId()).orElse("NO MOD INFO AVAILABLE"));
|
||||||
category.applyStackTrace(mle.getCause());
|
Throwable cause = mle.getCause();
|
||||||
category.addDetail("Failure message", mle.getCleanMessage());
|
int depth = 0;
|
||||||
category.addDetail("Exception message", Objects.toString(mle.getCause(), "MISSING EXCEPTION MESSAGE"));
|
while (cause != null && cause.getCause() != null && cause.getCause()!=cause) {
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
category.applyStackTrace(cause);
|
||||||
|
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("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"));
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue