Skip to content

Commit dd1f137

Browse files
authored
Fix: Improve Error Message (#2750)
2 parents 1886322 + fdc295a commit dd1f137

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

CHANGES.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Unreleased
1111
- ``_plain_int`` and ``_plain_float`` strip whitespace before type
1212
enforcement. :issue:`2734`
1313
- Fix empty file streaming when testing. :issue:`2740`
14+
- Clearer error message when URL rule does not start with slash. :pr:`2750`
1415

1516

1617
Version 2.3.6

src/werkzeug/routing/rules.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,8 @@ def __init__(
454454
websocket: bool = False,
455455
) -> None:
456456
if not string.startswith("/"):
457-
raise ValueError("urls must start with a leading slash")
457+
raise ValueError(f"URL rule '{string}' must start with a slash.")
458+
458459
self.rule = string
459460
self.is_leaf = not string.endswith("/")
460461
self.is_branch = string.endswith("/")

0 commit comments

Comments
 (0)