Skip to content
This repository has been archived by the owner on Aug 22, 2019. It is now read-only.

raise exception if given wrong slot name #1644

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 7 additions & 7 deletions rasa_core/slots.py
Expand Up @@ -63,17 +63,17 @@ def __repr__(self):
@staticmethod
def resolve_by_type(type_name):
"""Returns a slots class by its type name."""

for cls in utils.all_subclasses(Slot):
if cls.type_name == type_name:
return cls
try:
return utils.class_from_module_path(type_name)
except Exception:
cls = utils.class_from_module_path(type_name)
if cls:
return cls
else:
raise ValueError(
"Failed to find slot type. Neither a known type nor. If "
"you are creating your own slot type, make sure its "
"module path is correct: {}.".format(type_name))
"Failed to find slot type, '{}' is neither a known type nor "
"user-defined. If you are creating your own slot type, make "
"sure its module path is correct:".format(type_name))

def persistence_info(self):
return {"type": utils.module_path_from_instance(self),
Expand Down
2 changes: 1 addition & 1 deletion tests/test_domain.py
Expand Up @@ -159,7 +159,7 @@ def test_domain_fails_on_unknown_custom_slot_type(tmpdir):

actions:
- utter_greet""")
with pytest.raises(ValueError):
with pytest.raises(AttributeError):
Domain.load(domain_path)


Expand Down