mentioning expected recipe type in error messages (makes it easier figuring out issues when overwriting recipes that had a non-default = shaped type)

This commit is contained in:
Florian Nücke 2013-12-28 17:55:27 +01:00
parent 34f06cecfc
commit fbb1fd748b

View File

@ -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 {
val recipeType = tryGetType(recipe)
try {
recipeType 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 + "'.")
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)