Skip to content

Commit

Permalink
Added 421 Misdirected Request HTTP Exception
Browse files Browse the repository at this point in the history
  • Loading branch information
charan-kumar-137 committed May 16, 2024
1 parent e87f60b commit b10d382
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
2 changes: 2 additions & 0 deletions docs/exceptions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ The following error classes exist in Werkzeug:

.. autoexception:: ImATeapot

.. autoexception:: MisdirectedRequest

.. autoexception:: UnprocessableEntity

.. autoexception:: Locked
Expand Down
13 changes: 13 additions & 0 deletions src/werkzeug/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,19 @@ class ImATeapot(HTTPException):
description = "This server is a teapot, not a coffee machine"


class MisdirectedRequest(HTTPException):
"""*421* `Misdirected Request`
Indicates that the request was directed to a proxy
that is unable to produce a response.
"""

code = 421
description = (
"the request was directed to a proxy" " that is unable to produce a response."
)


class UnprocessableEntity(HTTPException):
"""*422* `Unprocessable Entity`
Expand Down
3 changes: 3 additions & 0 deletions tests/test_exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ def test_aborter_custom():
pytest.raises(exceptions.NotFound, myabort, 404)
pytest.raises(exceptions.NotFound, myabort, 1)

myabort = exceptions.Aborter()
pytest.raises(exceptions.MisdirectedRequest, myabort, 421)


def test_exception_repr():
exc = exceptions.NotFound()
Expand Down

0 comments on commit b10d382

Please sign in to comment.