Skip to content

Commit

Permalink
Protect against ItemStack crashes in ErrorUtil logging (#500)
Browse files Browse the repository at this point in the history
  • Loading branch information
mezz committed Oct 5, 2016
1 parent 2a28633 commit 225f10c
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions src/main/java/mezz/jei/util/ErrorUtil.java
Expand Up @@ -149,15 +149,25 @@ public static List<String> getItemStackIngredientsInfo(@Nullable List list) {
for (Object ingredient : list) {
List<String> ingredientInfo = new ArrayList<String>();

List<ItemStack> stacks = stackHelper.toItemStackList(ingredient);
String oreDict = stackHelper.getOreDictEquivalent(stacks);
if (oreDict != null) {
ingredientInfo.add("OreDict: " + oreDict);
List<ItemStack> stacks = null;
try {
stacks = stackHelper.toItemStackList(ingredient);
} catch (RuntimeException ignored) {
ingredientInfo.add("too broken to get info");
} catch (LinkageError ignored) {
ingredientInfo.add("too broken to get info");
}

if (stacks != null) {
String oreDict = stackHelper.getOreDictEquivalent(stacks);
if (oreDict != null) {
ingredientInfo.add("OreDict: " + oreDict);
}

for (ItemStack stack : stacks) {
String itemStackInfo = getItemStackInfo(stack);
ingredientInfo.add(itemStackInfo);
for (ItemStack stack : stacks) {
String itemStackInfo = getItemStackInfo(stack);
ingredientInfo.add(itemStackInfo);
}
}

ingredientsInfo.add(ingredientInfo.toString() + "\n");
Expand Down

0 comments on commit 225f10c

Please sign in to comment.