Core: adds a custom KeyError for invalid item names (#4223)
* adds a custom KeyError for raising on world.create_item() if the passed in name is invalid * Update __init__.py --------- Co-authored-by: Exempt-Medic <60412657+Exempt-Medic@users.noreply.github.com>
This commit is contained in:
@@ -22,6 +22,10 @@ if TYPE_CHECKING:
|
|||||||
perf_logger = logging.getLogger("performance")
|
perf_logger = logging.getLogger("performance")
|
||||||
|
|
||||||
|
|
||||||
|
class InvalidItemError(KeyError):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
class AutoWorldRegister(type):
|
class AutoWorldRegister(type):
|
||||||
world_types: Dict[str, Type[World]] = {}
|
world_types: Dict[str, Type[World]] = {}
|
||||||
__file__: str
|
__file__: str
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import logging
|
|||||||
|
|
||||||
from BaseClasses import Item, Tutorial, ItemClassification
|
from BaseClasses import Item, Tutorial, ItemClassification
|
||||||
|
|
||||||
from ..AutoWorld import World, WebWorld
|
from ..AutoWorld import InvalidItemError, World, WebWorld
|
||||||
from NetUtils import SlotType
|
from NetUtils import SlotType
|
||||||
|
|
||||||
|
|
||||||
@@ -47,7 +47,7 @@ class GenericWorld(World):
|
|||||||
def create_item(self, name: str) -> Item:
|
def create_item(self, name: str) -> Item:
|
||||||
if name == "Nothing":
|
if name == "Nothing":
|
||||||
return Item(name, ItemClassification.filler, -1, self.player)
|
return Item(name, ItemClassification.filler, -1, self.player)
|
||||||
raise KeyError(name)
|
raise InvalidItemError(name)
|
||||||
|
|
||||||
|
|
||||||
class PlandoItem(NamedTuple):
|
class PlandoItem(NamedTuple):
|
||||||
|
|||||||
Reference in New Issue
Block a user