Skip to content

Exceptions

tilttek/inventory

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

ExceptionThrown whenMessage
InventoryRefusedThe inventory's rules refuse the act; refusal says whyThe refusal's message, below
UnknownInventoryNo inventory holds the reference, or no item the keyNo inventory is known as "…"., The inventory "…" holds no item under the key "…".
InvalidInventoryA name, a key, a reason, a quantity, a burden, a container, a place, carrying rules, a capacity or a limit out of bounds; part of a stack moved without a new key; a transfer to the same inventoryWhat is out of bounds, and the bound

InventoryRefused extends DomainException, UnknownInventory OutOfBoundsException, InvalidInventory InvalidArgumentException.

RefusalMessage
AlreadyOpenAn inventory already holds this reference.
TooManyInventoriesThis owner holds as many inventories as allowed.
ItemExistsThe inventory already holds an item under this key.
TooManyItemsThe inventory holds as many items as allowed.
NotEnoughThe inventory holds fewer of this item than asked.
NotAContainerThis item is not a container.
ContainerCycleA container cannot go inside itself or what it holds.
TooDeepContainers would nest deeper than allowed.
ContainerFullThe container cannot hold this much.
ContainerNotEmptyThe container still holds items.
SingleContainerA container is always a single item.
NotCarriedOnly an item a carrier holds in hand or on them can be equipped.
OverCapacityThe carrier cannot carry this much.

A new value is checked before the limits and the keys already taken: opening an inventory or adding an item with an invalid name or key throws InvalidInventory even when the reference or the key is already taken. A container the destination names but the inventory does not hold throws UnknownInventory.