Merge ~cjwatson/lazr.restful:simplify-error-status-tests into lazr.restful:main

Proposed by Colin Watson
Status: Merged
Merged at revision: e99f1d0efa67f15ad8dff3b6b66951476be3dee7
Proposed branch: ~cjwatson/lazr.restful:simplify-error-status-tests
Merge into: lazr.restful:main
Diff against target: 47 lines (+5/-17)
2 files modified
src/lazr/restful/declarations.py (+1/-1)
src/lazr/restful/docs/webservice-declarations.rst (+4/-16)
Reviewer Review Type Date Requested Status
Jürgen Gmach Approve
Review via email: mp+413871@code.launchpad.net

Commit message

Simplify error_status tests

To post a comment you must log in.
Revision history for this message
Jürgen Gmach (jugmac00) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/src/lazr/restful/declarations.py b/src/lazr/restful/declarations.py
2index 1ea9e21..0fca6c1 100644
3--- a/src/lazr/restful/declarations.py
4+++ b/src/lazr/restful/declarations.py
5@@ -547,7 +547,7 @@ def webservice_error(status):
6
7
8 def error_status(status):
9- """Make a Python 2.6 class decorator for the given status.
10+ """Make a class decorator for the given status.
11
12 Usage 1:
13 @error_status(400)
14diff --git a/src/lazr/restful/docs/webservice-declarations.rst b/src/lazr/restful/docs/webservice-declarations.rst
15index 2a8eb46..8c66e30 100644
16--- a/src/lazr/restful/docs/webservice-declarations.rst
17+++ b/src/lazr/restful/docs/webservice-declarations.rst
18@@ -675,25 +675,13 @@ Exporting exceptions
19
20 When a method raises an exception, the default is to report the error as
21 '500 Internal Server Error'. In many cases, that's not the case and one
22-of the 4XX error would be better.
23-
24-For Python 2.6 or higher, or for annotating an already existing exception,
25-you can use error_status.
26-
27-In Python 2.6, you would spell this as follows::
28-
29- from lazr.restful.declarations import error_status
30- @error_status(400)
31- class InvalidDemo(Exception):
32- """An example exception"""
33-
34-In earlier Pythons it is still usable.
35+of the 4XX error would be better. You can use error_status to annotate an
36+exception with a suitable HTTP status.
37
38 >>> from lazr.restful.declarations import error_status
39- >>> class InvalidDemo(Exception):
40+ >>> @error_status(400)
41+ ... class InvalidDemo(Exception):
42 ... """An example exception"""
43- ...
44- >>> ignore = error_status(400)(InvalidDemo)
45
46 The function sets the __lazr_webservice_error__ attribute on the
47 exception, which will be used by the view handling the exception.

Subscribers

People subscribed via source and target branches