improve error message for methods argument in HTTP method decorators
Clarify the TypeError raised when passing 'methods' to HTTP method decorators (get, post, etc.) by indicating which decorator was used and explicitly stating to use 'route' instead.
This commit is contained in:
parent
954f5684e4
commit
b70441f721
1 changed files with 4 additions and 1 deletions
|
|
@ -288,7 +288,10 @@ class Scaffold:
|
|||
options: dict[str, t.Any],
|
||||
) -> t.Callable[[T_route], T_route]:
|
||||
if "methods" in options:
|
||||
raise TypeError("Use the 'route' decorator to use the 'methods' argument.")
|
||||
raise TypeError(
|
||||
"The 'methods' argument is not allowed when using "
|
||||
f"'{method.lower()}' decorator. Use the 'route' decorator instead."
|
||||
)
|
||||
|
||||
return self.route(rule, methods=[method], **options)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue