Skip to content

Exceptions

tilttek/crafting

Every exception of the library implements Exception\CraftingException: catch this one to catch them all.

ExceptionThrown whenMessage
InvalidRecipeA code, a quantity, a recipe, a book, a selection, a key, repetitions or a limit out of boundsWhat is out of bounds, and the bound
RecipeNotFoundThe book holds no recipe of that codeThe recipe book holds no recipe "…".
CraftRefusedItems are missing, a key made another craft, or the inventory refusedWhy, with what is missing

InvalidRecipe extends InvalidArgumentException, RecipeNotFound OutOfBoundsException and CraftRefused RuntimeException.

The messages of InvalidRecipe

ValueMessage
A codeThe code of an item must be 1 to 96 lowercase letters, digits, "_", "-" or single dots between them; "…" is not., and likewise for a recipe, a tag, an attribute and a protected item
A quantityThe quantity of the ingredient … is 1 to 999; it is …., and likewise for the others
A keyThe key of a craft is 1 to 191 visible ASCII characters, without spaces.
The tags of a holdingAn item carries at most 16 tags; "…" has ….
The ingredientsThe recipe "…" lists 1 to 16 ingredients; it has ….
An ingredient named twiceThe recipe "…" names the ingredient … twice.
Tools onlyThe recipe "…" consumes at least one ingredient; tools alone produce nothing.
The outputs or items given backThe recipe "…" lists 1 to 8 outputs; it has …., The recipe "…" names "…" twice among its outputs.
An output's quantityThe quantity of "…" in the recipe "…" is 1 to 999; it is ….
The attributesA recipe carries at most 10 attributes; "…" has …., The attribute "…" is 1 to 100 characters of UTF-8 without control characters nor surrounding spaces.
An evolving recipeThe evolving recipe "…" takes its first ingredient, one item named by its code, and consumes it., The evolving recipe "…" produces one item of another kind than "…".
The bookA recipe book holds at most 1000 recipes; this one has …., The recipe book holds the recipe "…" twice.
A protected itemThe recipe "…" consumes "…", which no craft may consume.
Plain valuesA recipe book has no "…"; it knows recipes., and a message naming the value and its expected form for every other
A selectionA selection names the ingredients by their position, 0 to 15; … is not one., A selection chooses 1 to 16 items for an ingredient; … were chosen for the ingredient ….
A choiceA selection chooses items for an ingredient asked by a tag; the ingredient … of the recipe "…" is not one., The items chosen for the ingredient … of the recipe "…" add up to …; it needs …., "…" cannot serve the ingredient … of the recipe "…".
The closest recipesThe closest recipes are 1 to 50; … is out of bounds.

The messages of CraftRefused

CaseMessage
Items missingThe recipe "…" cannot be crafted: 1 × #metal, 2 × iron missing.
A key that made another craftThe key "…" already made another craft.
A key recorded without its craftThe key "…" is recorded, yet its craft cannot be read.
Too many holdingsThe crafter reads at most 10000 holdings of a holder.
An item given twiceThe inventory gives one holding per item; "…" came twice.
The in-memory inventoryThe craft "…" needs … × "…"; the holder has ….

The exceptions of phil/resource reach the caller unchanged when a reference is malformed.