mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-21 20:52:34 +00:00
Improve exception messages during initialization.
This commit is contained in:
1 parent
64c9aae0c4
commit
bd4fe54753
12 files changed
+366
-125
No files matched your search
@@ -236,6 +236,8 @@ public class Loader
|
||||
private void sortModList()
|
||||
{
|
||||
FMLLog.finer("Verifying mod requirements are satisfied");
|
||||
List<WrongMinecraftVersionException> wrongMinecraftExceptions = new ArrayList<WrongMinecraftVersionException>();
|
||||
List<MissingModsException> missingModsExceptions = new ArrayList<MissingModsException>();
|
||||
try
|
||||
{
|
||||
BiMap<String, ArtifactVersion> modVersions = HashBiMap.create();
|
||||
@@ -250,9 +252,10 @@ 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());
|
||||
RuntimeException ret = new WrongMinecraftVersionException(mod, getMCVersionString());
|
||||
WrongMinecraftVersionException ret = new WrongMinecraftVersionException(mod, getMCVersionString());
|
||||
FMLLog.severe(ret.getMessage());
|
||||
throw ret;
|
||||
wrongMinecraftExceptions.add(ret);
|
||||
continue;
|
||||
}
|
||||
Map<String,ArtifactVersion> names = Maps.uniqueIndex(mod.getRequirements(), new ArtifactVersionNameFunction());
|
||||
Set<ArtifactVersion> versionMissingMods = Sets.newHashSet();
|
||||
@@ -265,9 +268,10 @@ public class Loader
|
||||
{
|
||||
versionMissingMods.add(names.get(modid));
|
||||
}
|
||||
RuntimeException ret = new MissingModsException(versionMissingMods, mod.getModId(), mod.getName());
|
||||
MissingModsException ret = new MissingModsException(versionMissingMods, mod.getModId(), mod.getName());
|
||||
FMLLog.severe(ret.getMessage());
|
||||
throw ret;
|
||||
missingModsExceptions.add(ret);
|
||||
continue;
|
||||
}
|
||||
reqList.putAll(mod.getModId(), names.keySet());
|
||||
ImmutableList<ArtifactVersion> allDeps = ImmutableList.<ArtifactVersion>builder().addAll(mod.getDependants()).addAll(mod.getDependencies()).build();
|
||||
@@ -284,13 +288,28 @@ public class Loader
|
||||
if (!versionMissingMods.isEmpty())
|
||||
{
|
||||
FMLLog.severe("The mod %s (%s) requires mod versions %s to be available", mod.getModId(), mod.getName(), versionMissingMods);
|
||||
RuntimeException ret = new MissingModsException(versionMissingMods, mod.getModId(), mod.getName());
|
||||
MissingModsException ret = new MissingModsException(versionMissingMods, mod.getModId(), mod.getName());
|
||||
FMLLog.severe(ret.toString());
|
||||
throw ret;
|
||||
missingModsExceptions.add(ret);
|
||||
}
|
||||
}
|
||||
|
||||
FMLLog.finer("All mod requirements are satisfied");
|
||||
if (wrongMinecraftExceptions.isEmpty() && missingModsExceptions.isEmpty())
|
||||
{
|
||||
FMLLog.finer("All mod requirements are satisfied");
|
||||
}
|
||||
else if (missingModsExceptions.size()==1 && wrongMinecraftExceptions.isEmpty())
|
||||
{
|
||||
throw missingModsExceptions.get(0);
|
||||
}
|
||||
else if (wrongMinecraftExceptions.size()==1 && missingModsExceptions.isEmpty())
|
||||
{
|
||||
throw wrongMinecraftExceptions.get(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new MultipleModsErrored(wrongMinecraftExceptions, missingModsExceptions);
|
||||
}
|
||||
|
||||
reverseDependencies = Multimaps.invertFrom(reqList, ArrayListMultimap.<String,String>create());
|
||||
ModSorter sorter = new ModSorter(getActiveModList(), namedMods);
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Minecraft Forge
|
||||
* Copyright (c) 2016.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
package net.minecraftforge.fml.common;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class MultipleModsErrored extends RuntimeException
|
||||
{
|
||||
public final List<WrongMinecraftVersionException> wrongMinecraftExceptions;
|
||||
public final List<MissingModsException>missingModsExceptions;
|
||||
public MultipleModsErrored(List<WrongMinecraftVersionException> wrongMinecraftExceptions, List<MissingModsException> missingModsExceptions)
|
||||
{
|
||||
this.wrongMinecraftExceptions = wrongMinecraftExceptions;
|
||||
this.missingModsExceptions = missingModsExceptions;
|
||||
}
|
||||
}
|
||||
@@ -212,9 +212,9 @@ public class Restriction
|
||||
}
|
||||
else if ( getLowerBound() != null && getUpperBound() != null )
|
||||
{
|
||||
if ( getLowerBound().equals(getUpperBound()) )
|
||||
if ( getLowerBound().getVersionString().equals(getUpperBound().getVersionString()) )
|
||||
{
|
||||
return getLowerBound().toString();
|
||||
return getLowerBound().getVersionString();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user