mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-12 00:07:45 +00:00
Made WrongMinecraftVersionException and ModSortingException a bit easier to read in log files. Closes: #2345
This commit is contained in:
1 parent
76c40896e4
commit
afc46fa59a
3 files changed
+44
-6
No files matched your search
@@ -219,7 +219,9 @@ public class Loader
|
||||
if (!mod.acceptableMinecraftVersionRange().containsVersion(minecraft.getProcessedVersion()))
|
||||
{
|
||||
FMLLog.severe("The mod %s does not wish to run in Minecraft version %s. You will have to remove it to play.", mod.getModId(), getMCVersionString());
|
||||
throw new WrongMinecraftVersionException(mod);
|
||||
RuntimeException ret = new WrongMinecraftVersionException(mod, getMCVersionString());
|
||||
FMLLog.severe(ret.getMessage());
|
||||
throw ret;
|
||||
}
|
||||
Map<String,ArtifactVersion> names = Maps.uniqueIndex(mod.getRequirements(), new ArtifactVersionNameFunction());
|
||||
Set<ArtifactVersion> versionMissingMods = Sets.newHashSet();
|
||||
@@ -232,7 +234,9 @@ public class Loader
|
||||
{
|
||||
versionMissingMods.add(names.get(modid));
|
||||
}
|
||||
throw new MissingModsException(versionMissingMods, mod.getModId(), mod.getName());
|
||||
RuntimeException ret = new MissingModsException(versionMissingMods, mod.getModId(), mod.getName());
|
||||
FMLLog.severe(ret.getMessage());
|
||||
throw ret;
|
||||
}
|
||||
reqList.putAll(mod.getModId(), names.keySet());
|
||||
ImmutableList<ArtifactVersion> allDeps = ImmutableList.<ArtifactVersion>builder().addAll(mod.getDependants()).addAll(mod.getDependencies()).build();
|
||||
@@ -249,7 +253,9 @@ public class Loader
|
||||
if (!versionMissingMods.isEmpty())
|
||||
{
|
||||
FMLLog.severe("The mod %s (%s) requires mod versions %s to be available", mod.getModId(), mod.getName(), versionMissingMods);
|
||||
throw new MissingModsException(versionMissingMods, mod.getModId(), mod.getName());
|
||||
RuntimeException ret = new MissingModsException(versionMissingMods, mod.getModId(), mod.getName());
|
||||
FMLLog.severe(ret.toString());
|
||||
throw ret;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -12,15 +12,27 @@
|
||||
|
||||
package net.minecraftforge.fml.common;
|
||||
|
||||
public class WrongMinecraftVersionException extends RuntimeException
|
||||
public class WrongMinecraftVersionException extends EnhancedRuntimeException
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
public ModContainer mod;
|
||||
private String mcVersion;
|
||||
|
||||
public WrongMinecraftVersionException(ModContainer mod)
|
||||
public WrongMinecraftVersionException(ModContainer mod, String mcver)
|
||||
{
|
||||
super(String.format("Wrong Minecraft version for %s", mod.getModId()));
|
||||
this.mod = mod;
|
||||
this.mcVersion = mcver;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void printStackTrace(WrappedPrintStream stream) {
|
||||
stream.println("Wrong Minecraft Versions!");
|
||||
stream.println("Mod: " + mod.getModId());
|
||||
stream.println("Location: " + mod.getSource().toString());
|
||||
stream.println("Expected: " + mod.acceptableMinecraftVersionRange().toString());
|
||||
stream.println("Current: " + mcVersion);
|
||||
stream.println("");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -14,7 +14,14 @@ package net.minecraftforge.fml.common.toposort;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
public class ModSortingException extends RuntimeException
|
||||
import org.apache.logging.log4j.Level;
|
||||
|
||||
import net.minecraftforge.fml.common.EnhancedRuntimeException;
|
||||
import net.minecraftforge.fml.common.FMLLog;
|
||||
import net.minecraftforge.fml.common.ModContainer;
|
||||
import net.minecraftforge.fml.common.toposort.ModSortingException.SortingExceptionData;
|
||||
|
||||
public class ModSortingException extends EnhancedRuntimeException
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@@ -53,4 +60,17 @@ public class ModSortingException extends RuntimeException
|
||||
return (SortingExceptionData<T>) sortingExceptionData;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void printStackTrace(WrappedPrintStream stream)
|
||||
{
|
||||
SortingExceptionData<ModContainer> exceptionData = getExceptionData();
|
||||
stream.println("A dependency cycle was detected in the input mod set so an ordering cannot be determined");
|
||||
stream.println("The first mod in the cycle is " + exceptionData.getFirstBadNode());
|
||||
stream.println("The mod cycle involves:");
|
||||
for (ModContainer mc : exceptionData.getVisitedNodes())
|
||||
{
|
||||
stream.println(String.format("\t%s : before: %s, after: %s", mc.toString(), mc.getDependants(), mc.getDependencies()));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user