Skip to content

Commit 7dc0e19

Browse files
committed
More helpful exception
1 parent ee3c052 commit 7dc0e19

File tree

1 file changed

+2
-1
lines changed
  • labthings/server/spec

1 file changed

+2
-1
lines changed

labthings/server/spec/td.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,8 @@ def action(self, rules: list, view: View):
217217
NB at present this will fail for any view that doesn't support POST
218218
requests.
219219
"""
220-
assert hasattr(view, "post"), "Thing actions must have a POST method!"
220+
if not hasattr(view, "post"):
221+
raise AttributeError(f"The API View '{view}' was added as an Action, but it does not have a POST method.")
221222
endpoint = getattr(view, "endpoint") or getattr(rules[0], "endpoint")
222223
key = snake_to_camel(endpoint)
223224
self.actions[key] = self.view_to_thing_action(rules, view)

0 commit comments

Comments
 (0)