From fbb1fd748b1a16d7e6af3c474885c0227cd329a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20N=C3=BCcke?= Date: Sat, 28 Dec 2013 17:55:27 +0100 Subject: [PATCH] mentioning expected recipe type in error messages (makes it easier figuring out issues when overwriting recipes that had a non-default = shaped type) --- li/cil/oc/Recipes.scala | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/li/cil/oc/Recipes.scala b/li/cil/oc/Recipes.scala index 0d40926a6..90f9c16f9 100644 --- a/li/cil/oc/Recipes.scala +++ b/li/cil/oc/Recipes.scala @@ -129,11 +129,17 @@ object Recipes { def addRecipe(output: ItemStack, list: Config, name: String) = try { if (list.hasPath(name)) { val recipe = list.getConfig(name) - tryGetType(recipe) match { - case "shaped" => addShapedRecipe(output, recipe) - case "shapeless" => addShapelessRecipe(output, recipe) - case "furnace" => addFurnaceRecipe(output, recipe) - case other => throw new RecipeException("Invalid recipe type '" + other + "'.") + val recipeType = tryGetType(recipe) + try { + recipeType match { + case "shaped" => addShapedRecipe(output, recipe) + case "shapeless" => addShapelessRecipe(output, recipe) + case "furnace" => addFurnaceRecipe(output, recipe) + case other => OpenComputers.log.warning("Failed adding recipe for '" + name + "', you will not be able to craft this item! The error was: Invalid recipe type '" + other + "'.") + } + } + catch { + case e: RecipeException => OpenComputers.log.warning("Failed adding " + recipeType + " recipe for '" + name + "', you will not be able to craft this item! The error was: " + e.getMessage) } } else { @@ -141,7 +147,6 @@ object Recipes { } } catch { - case e: RecipeException => OpenComputers.log.warning("Failed adding recipe for '" + name + "', you will not be able to craft this item! The error was: " + e.getMessage) case e: Throwable => OpenComputers.log.log(Level.SEVERE, "Failed adding recipe for '" + name + "', you will not be able to craft this item!", e) } @@ -283,7 +288,8 @@ object Recipes { private def cartesianProduct[T](xss: List[List[T]]): List[List[T]] = xss match { case Nil => List(Nil) - case h :: t => for (xh <- h; xt <- cartesianProduct(t)) yield xh :: xt + case h :: t => for (xh <- h; + xt <- cartesianProduct(t)) yield xh :: xt } private class RecipeException(message: String) extends RuntimeException(message)