We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Error title should default to HTTP status
When the title is set to `None`, `HTTPError` should default to simply reusing the description passed in with the code in the `status` argument, i.e.: 

``` py
self.title = status_code[4:]
```


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `falcon/http_error.py`
Content:
```
1 # Copyright 2013 by Rackspace Hosting, Inc.
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 #    http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14 
15 """HTTPError exception class."""
16 
17 import json
18 import xml.etree.ElementTree as et
19 
20 try:
21     from collections import OrderedDict
22 except ImportError:
23     OrderedDict = dict
24 
25 from falcon.util import uri
26 
27 
28 class HTTPError(Exception):
29     """Represents a generic HTTP error.
30 
31     Raise this or a child class to have Falcon automagically return pretty
32     error responses (with an appropriate HTTP status code) to the client
33     when something goes wrong.
34 
35     Attributes:
36         status (str): HTTP status line, e.g. '748 Confounded by Ponies'.
37         has_representation (bool): Read-only property that determines
38             whether error details will be serialized when composing
39             the HTTP response. In ``HTTPError`` this property always
40             returns ``True``, but child classes may override it
41             in order to return ``False`` when an empty HTTP body is desired.
42             See also the ``falcon.http_error.NoRepresentation`` mixin.
43         title (str): Error title to send to the client. Will be ``None`` if
44             the error should result in an HTTP response with an empty body.
45         description (str): Description of the error to send to the client.
46         headers (dict): Extra headers to add to the response.
47         link (str): An href that the client can provide to the user for
48             getting help.
49         code (int): An internal application code that a user can reference when
50             requesting support for the error.
51 
52     Args:
53         status (str): HTTP status code and text, such as "400 Bad Request"
54 
55     Keyword Args:
56         title (str): Human-friendly error title (default ``None``).
57         description (str): Human-friendly description of the error, along with
58             a helpful suggestion or two (default ``None``).
59         headers (dict or list): A ``dict`` of header names and values
60             to set, or a ``list`` of (*name*, *value*) tuples. Both *name* and
61             *value* must be of type ``str`` or ``StringType``, and only
62             character values 0x00 through 0xFF may be used on platforms that
63             use wide characters.
64 
65             Note:
66                 The Content-Type header, if present, will be overridden. If
67                 you wish to return custom error messages, you can create
68                 your own HTTP error class, and install an error handler
69                 to convert it into an appropriate HTTP response for the
70                 client
71 
72             Note:
73                 Falcon can process a list of ``tuple`` slightly faster
74                 than a ``dict``.
75 
76         headers (dict): Extra headers to return in the
77             response to the client (default ``None``).
78         href (str): A URL someone can visit to find out more information
79             (default ``None``). Unicode characters are percent-encoded.
80         href_text (str): If href is given, use this as the friendly
81             title/description for the link (defaults to "API documentation
82             for this error").
83         code (int): An internal code that customers can reference in their
84             support request or to help them when searching for knowledge
85             base articles related to this error (default ``None``).
86     """
87 
88     __slots__ = (
89         'status',
90         'title',
91         'description',
92         'headers',
93         'link',
94         'code',
95     )
96 
97     def __init__(self, status, title=None, description=None, headers=None,
98                  href=None, href_text=None, code=None):
99         self.status = status
100         self.title = title
101         self.description = description
102         self.headers = headers
103         self.code = code
104 
105         if href:
106             link = self.link = OrderedDict()
107             link['text'] = (href_text or 'Documentation related to this error')
108             link['href'] = uri.encode(href)
109             link['rel'] = 'help'
110         else:
111             self.link = None
112 
113     @property
114     def has_representation(self):
115         return True
116 
117     def to_dict(self, obj_type=dict):
118         """Returns a basic dictionary representing the error.
119 
120         This method can be useful when serializing the error to hash-like
121         media types, such as YAML, JSON, and MessagePack.
122 
123         Args:
124             obj_type: A dict-like type that will be used to store the
125                 error information (default ``dict``).
126 
127         Returns:
128             A dictionary populated with the error's title, description, etc.
129 
130         """
131 
132         assert self.has_representation
133 
134         obj = obj_type()
135 
136         if self.title is not None:
137             obj['title'] = self.title
138 
139         if self.description is not None:
140             obj['description'] = self.description
141 
142         if self.code is not None:
143             obj['code'] = self.code
144 
145         if self.link is not None:
146             obj['link'] = self.link
147 
148         return obj
149 
150     def to_json(self):
151         """Returns a pretty-printed JSON representation of the error.
152 
153         Returns:
154             A JSON document for the error.
155 
156         """
157 
158         obj = self.to_dict(OrderedDict)
159         return json.dumps(obj, indent=4, separators=(',', ': '),
160                           ensure_ascii=False)
161 
162     def to_xml(self):
163         """Returns an XML-encoded representation of the error.
164 
165         Returns:
166             An XML document for the error.
167 
168         """
169 
170         assert self.has_representation
171 
172         error_element = et.Element('error')
173 
174         if self.title is not None:
175             et.SubElement(error_element, 'title').text = self.title
176 
177         if self.description is not None:
178             et.SubElement(error_element, 'description').text = self.description
179 
180         if self.code is not None:
181             et.SubElement(error_element, 'code').text = str(self.code)
182 
183         if self.link is not None:
184             link_element = et.SubElement(error_element, 'link')
185 
186             for key in ('text', 'href', 'rel'):
187                 et.SubElement(link_element, key).text = self.link[key]
188 
189         return (b'<?xml version="1.0" encoding="UTF-8"?>' +
190                 et.tostring(error_element, encoding='utf-8'))
191 
192 
193 class NoRepresentation(object):
194     """Mixin for ``HTTPError`` child classes that have no representation.
195 
196     This class can be mixed in when inheriting from ``HTTPError``, in order
197     to override the `has_representation` property such that it always
198     returns ``False``. This, in turn, will cause Falcon to return an empty
199     response body to the client.
200 
201     You can use this mixin when defining errors that either should not have
202     a body (as dictated by HTTP standards or common practice), or in the
203     case that a detailed error response may leak information to an attacker.
204 
205     Note:
206         This mixin class must appear before ``HTTPError`` in the base class
207         list when defining the child; otherwise, it will not override the
208         `has_representation` property as expected.
209 
210     """
211 
212     @property
213     def has_representation(self):
214         return False
215 
216 
217 class OptionalRepresentation(object):
218     """Mixin for ``HTTPError`` child classes that may have a representation.
219 
220     This class can be mixed in when inheriting from ``HTTPError`` in order
221     to override the `has_representation` property, such that it will
222     return ``False`` when the error instance has no description
223     (i.e., the `description` kwarg was not set).
224 
225     You can use this mixin when defining errors that do not include
226     a body in the HTTP response by default, serializing details only when
227     the web developer provides a description of the error.
228 
229     Note:
230         This mixin class must appear before ``HTTPError`` in the base class
231         list when defining the child; otherwise, it will not override the
232         `has_representation` property as expected.
233 
234     """
235     @property
236     def has_representation(self):
237         return super(OptionalRepresentation, self).description is not None
238
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/falcon/http_error.py b/falcon/http_error.py
--- a/falcon/http_error.py
+++ b/falcon/http_error.py
@@ -40,8 +40,7 @@
             returns ``True``, but child classes may override it
             in order to return ``False`` when an empty HTTP body is desired.
             See also the ``falcon.http_error.NoRepresentation`` mixin.
-        title (str): Error title to send to the client. Will be ``None`` if
-            the error should result in an HTTP response with an empty body.
+        title (str): Error title to send to the client.
         description (str): Description of the error to send to the client.
         headers (dict): Extra headers to add to the response.
         link (str): An href that the client can provide to the user for
@@ -53,7 +52,8 @@
         status (str): HTTP status code and text, such as "400 Bad Request"
 
     Keyword Args:
-        title (str): Human-friendly error title (default ``None``).
+        title (str): Human-friendly error title. If not provided, defaults
+            to the HTTP status line as determined by the ``status`` argument.
         description (str): Human-friendly description of the error, along with
             a helpful suggestion or two (default ``None``).
         headers (dict or list): A ``dict`` of header names and values
@@ -97,7 +97,13 @@
     def __init__(self, status, title=None, description=None, headers=None,
                  href=None, href_text=None, code=None):
         self.status = status
-        self.title = title
+
+        # TODO(kgriffs): HTTP/2 does away with the "reason phrase". Eventually
+        #   we'll probably switch over to making everything code-based to more
+        #   easily support HTTP/2. When that happens, should we continue to
+        #   include the reason phrase in the title?
+        self.title = title or status
+
         self.description = description
         self.headers = headers
         self.code = code
@@ -133,8 +139,7 @@
 
         obj = obj_type()
 
-        if self.title is not None:
-            obj['title'] = self.title
+        obj['title'] = self.title
 
         if self.description is not None:
             obj['description'] = self.description
@@ -171,8 +176,7 @@
 
         error_element = et.Element('error')
 
-        if self.title is not None:
-            et.SubElement(error_element, 'title').text = self.title
+        et.SubElement(error_element, 'title').text = self.title
 
         if self.description is not None:
             et.SubElement(error_element, 'description').text = self.description

{"golden_diff": "diff --git a/falcon/http_error.py b/falcon/http_error.py\n--- a/falcon/http_error.py\n+++ b/falcon/http_error.py\n@@ -40,8 +40,7 @@\n             returns ``True``, but child classes may override it\n             in order to return ``False`` when an empty HTTP body is desired.\n             See also the ``falcon.http_error.NoRepresentation`` mixin.\n-        title (str): Error title to send to the client. Will be ``None`` if\n-            the error should result in an HTTP response with an empty body.\n+        title (str): Error title to send to the client.\n         description (str): Description of the error to send to the client.\n         headers (dict): Extra headers to add to the response.\n         link (str): An href that the client can provide to the user for\n@@ -53,7 +52,8 @@\n         status (str): HTTP status code and text, such as \"400 Bad Request\"\n \n     Keyword Args:\n-        title (str): Human-friendly error title (default ``None``).\n+        title (str): Human-friendly error title. If not provided, defaults\n+            to the HTTP status line as determined by the ``status`` argument.\n         description (str): Human-friendly description of the error, along with\n             a helpful suggestion or two (default ``None``).\n         headers (dict or list): A ``dict`` of header names and values\n@@ -97,7 +97,13 @@\n     def __init__(self, status, title=None, description=None, headers=None,\n                  href=None, href_text=None, code=None):\n         self.status = status\n-        self.title = title\n+\n+        # TODO(kgriffs): HTTP/2 does away with the \"reason phrase\". Eventually\n+        #   we'll probably switch over to making everything code-based to more\n+        #   easily support HTTP/2. When that happens, should we continue to\n+        #   include the reason phrase in the title?\n+        self.title = title or status\n+\n         self.description = description\n         self.headers = headers\n         self.code = code\n@@ -133,8 +139,7 @@\n \n         obj = obj_type()\n \n-        if self.title is not None:\n-            obj['title'] = self.title\n+        obj['title'] = self.title\n \n         if self.description is not None:\n             obj['description'] = self.description\n@@ -171,8 +176,7 @@\n \n         error_element = et.Element('error')\n \n-        if self.title is not None:\n-            et.SubElement(error_element, 'title').text = self.title\n+        et.SubElement(error_element, 'title').text = self.title\n \n         if self.description is not None:\n             et.SubElement(error_element, 'description').text = self.description\n", "issue": "Error title should default to HTTP status\nWhen the title is set to `None`, `HTTPError` should default to simply reusing the description passed in with the code in the `status` argument, i.e.: \n\n``` py\nself.title = status_code[4:]\n```\n\n", "before_files": [{"content": "# Copyright 2013 by Rackspace Hosting, Inc.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#    http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\n\"\"\"HTTPError exception class.\"\"\"\n\nimport json\nimport xml.etree.ElementTree as et\n\ntry:\n    from collections import OrderedDict\nexcept ImportError:\n    OrderedDict = dict\n\nfrom falcon.util import uri\n\n\nclass HTTPError(Exception):\n    \"\"\"Represents a generic HTTP error.\n\n    Raise this or a child class to have Falcon automagically return pretty\n    error responses (with an appropriate HTTP status code) to the client\n    when something goes wrong.\n\n    Attributes:\n        status (str): HTTP status line, e.g. '748 Confounded by Ponies'.\n        has_representation (bool): Read-only property that determines\n            whether error details will be serialized when composing\n            the HTTP response. In ``HTTPError`` this property always\n            returns ``True``, but child classes may override it\n            in order to return ``False`` when an empty HTTP body is desired.\n            See also the ``falcon.http_error.NoRepresentation`` mixin.\n        title (str): Error title to send to the client. Will be ``None`` if\n            the error should result in an HTTP response with an empty body.\n        description (str): Description of the error to send to the client.\n        headers (dict): Extra headers to add to the response.\n        link (str): An href that the client can provide to the user for\n            getting help.\n        code (int): An internal application code that a user can reference when\n            requesting support for the error.\n\n    Args:\n        status (str): HTTP status code and text, such as \"400 Bad Request\"\n\n    Keyword Args:\n        title (str): Human-friendly error title (default ``None``).\n        description (str): Human-friendly description of the error, along with\n            a helpful suggestion or two (default ``None``).\n        headers (dict or list): A ``dict`` of header names and values\n            to set, or a ``list`` of (*name*, *value*) tuples. Both *name* and\n            *value* must be of type ``str`` or ``StringType``, and only\n            character values 0x00 through 0xFF may be used on platforms that\n            use wide characters.\n\n            Note:\n                The Content-Type header, if present, will be overridden. If\n                you wish to return custom error messages, you can create\n                your own HTTP error class, and install an error handler\n                to convert it into an appropriate HTTP response for the\n                client\n\n            Note:\n                Falcon can process a list of ``tuple`` slightly faster\n                than a ``dict``.\n\n        headers (dict): Extra headers to return in the\n            response to the client (default ``None``).\n        href (str): A URL someone can visit to find out more information\n            (default ``None``). Unicode characters are percent-encoded.\n        href_text (str): If href is given, use this as the friendly\n            title/description for the link (defaults to \"API documentation\n            for this error\").\n        code (int): An internal code that customers can reference in their\n            support request or to help them when searching for knowledge\n            base articles related to this error (default ``None``).\n    \"\"\"\n\n    __slots__ = (\n        'status',\n        'title',\n        'description',\n        'headers',\n        'link',\n        'code',\n    )\n\n    def __init__(self, status, title=None, description=None, headers=None,\n                 href=None, href_text=None, code=None):\n        self.status = status\n        self.title = title\n        self.description = description\n        self.headers = headers\n        self.code = code\n\n        if href:\n            link = self.link = OrderedDict()\n            link['text'] = (href_text or 'Documentation related to this error')\n            link['href'] = uri.encode(href)\n            link['rel'] = 'help'\n        else:\n            self.link = None\n\n    @property\n    def has_representation(self):\n        return True\n\n    def to_dict(self, obj_type=dict):\n        \"\"\"Returns a basic dictionary representing the error.\n\n        This method can be useful when serializing the error to hash-like\n        media types, such as YAML, JSON, and MessagePack.\n\n        Args:\n            obj_type: A dict-like type that will be used to store the\n                error information (default ``dict``).\n\n        Returns:\n            A dictionary populated with the error's title, description, etc.\n\n        \"\"\"\n\n        assert self.has_representation\n\n        obj = obj_type()\n\n        if self.title is not None:\n            obj['title'] = self.title\n\n        if self.description is not None:\n            obj['description'] = self.description\n\n        if self.code is not None:\n            obj['code'] = self.code\n\n        if self.link is not None:\n            obj['link'] = self.link\n\n        return obj\n\n    def to_json(self):\n        \"\"\"Returns a pretty-printed JSON representation of the error.\n\n        Returns:\n            A JSON document for the error.\n\n        \"\"\"\n\n        obj = self.to_dict(OrderedDict)\n        return json.dumps(obj, indent=4, separators=(',', ': '),\n                          ensure_ascii=False)\n\n    def to_xml(self):\n        \"\"\"Returns an XML-encoded representation of the error.\n\n        Returns:\n            An XML document for the error.\n\n        \"\"\"\n\n        assert self.has_representation\n\n        error_element = et.Element('error')\n\n        if self.title is not None:\n            et.SubElement(error_element, 'title').text = self.title\n\n        if self.description is not None:\n            et.SubElement(error_element, 'description').text = self.description\n\n        if self.code is not None:\n            et.SubElement(error_element, 'code').text = str(self.code)\n\n        if self.link is not None:\n            link_element = et.SubElement(error_element, 'link')\n\n            for key in ('text', 'href', 'rel'):\n                et.SubElement(link_element, key).text = self.link[key]\n\n        return (b'<?xml version=\"1.0\" encoding=\"UTF-8\"?>' +\n                et.tostring(error_element, encoding='utf-8'))\n\n\nclass NoRepresentation(object):\n    \"\"\"Mixin for ``HTTPError`` child classes that have no representation.\n\n    This class can be mixed in when inheriting from ``HTTPError``, in order\n    to override the `has_representation` property such that it always\n    returns ``False``. This, in turn, will cause Falcon to return an empty\n    response body to the client.\n\n    You can use this mixin when defining errors that either should not have\n    a body (as dictated by HTTP standards or common practice), or in the\n    case that a detailed error response may leak information to an attacker.\n\n    Note:\n        This mixin class must appear before ``HTTPError`` in the base class\n        list when defining the child; otherwise, it will not override the\n        `has_representation` property as expected.\n\n    \"\"\"\n\n    @property\n    def has_representation(self):\n        return False\n\n\nclass OptionalRepresentation(object):\n    \"\"\"Mixin for ``HTTPError`` child classes that may have a representation.\n\n    This class can be mixed in when inheriting from ``HTTPError`` in order\n    to override the `has_representation` property, such that it will\n    return ``False`` when the error instance has no description\n    (i.e., the `description` kwarg was not set).\n\n    You can use this mixin when defining errors that do not include\n    a body in the HTTP response by default, serializing details only when\n    the web developer provides a description of the error.\n\n    Note:\n        This mixin class must appear before ``HTTPError`` in the base class\n        list when defining the child; otherwise, it will not override the\n        `has_representation` property as expected.\n\n    \"\"\"\n    @property\n    def has_representation(self):\n        return super(OptionalRepresentation, self).description is not None\n", "path": "falcon/http_error.py"}], "after_files": [{"content": "# Copyright 2013 by Rackspace Hosting, Inc.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#    http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\n\"\"\"HTTPError exception class.\"\"\"\n\nimport json\nimport xml.etree.ElementTree as et\n\ntry:\n    from collections import OrderedDict\nexcept ImportError:\n    OrderedDict = dict\n\nfrom falcon.util import uri\n\n\nclass HTTPError(Exception):\n    \"\"\"Represents a generic HTTP error.\n\n    Raise this or a child class to have Falcon automagically return pretty\n    error responses (with an appropriate HTTP status code) to the client\n    when something goes wrong.\n\n    Attributes:\n        status (str): HTTP status line, e.g. '748 Confounded by Ponies'.\n        has_representation (bool): Read-only property that determines\n            whether error details will be serialized when composing\n            the HTTP response. In ``HTTPError`` this property always\n            returns ``True``, but child classes may override it\n            in order to return ``False`` when an empty HTTP body is desired.\n            See also the ``falcon.http_error.NoRepresentation`` mixin.\n        title (str): Error title to send to the client.\n        description (str): Description of the error to send to the client.\n        headers (dict): Extra headers to add to the response.\n        link (str): An href that the client can provide to the user for\n            getting help.\n        code (int): An internal application code that a user can reference when\n            requesting support for the error.\n\n    Args:\n        status (str): HTTP status code and text, such as \"400 Bad Request\"\n\n    Keyword Args:\n        title (str): Human-friendly error title. If not provided, defaults\n            to the HTTP status line as determined by the ``status`` argument.\n        description (str): Human-friendly description of the error, along with\n            a helpful suggestion or two (default ``None``).\n        headers (dict or list): A ``dict`` of header names and values\n            to set, or a ``list`` of (*name*, *value*) tuples. Both *name* and\n            *value* must be of type ``str`` or ``StringType``, and only\n            character values 0x00 through 0xFF may be used on platforms that\n            use wide characters.\n\n            Note:\n                The Content-Type header, if present, will be overridden. If\n                you wish to return custom error messages, you can create\n                your own HTTP error class, and install an error handler\n                to convert it into an appropriate HTTP response for the\n                client\n\n            Note:\n                Falcon can process a list of ``tuple`` slightly faster\n                than a ``dict``.\n\n        headers (dict): Extra headers to return in the\n            response to the client (default ``None``).\n        href (str): A URL someone can visit to find out more information\n            (default ``None``). Unicode characters are percent-encoded.\n        href_text (str): If href is given, use this as the friendly\n            title/description for the link (defaults to \"API documentation\n            for this error\").\n        code (int): An internal code that customers can reference in their\n            support request or to help them when searching for knowledge\n            base articles related to this error (default ``None``).\n    \"\"\"\n\n    __slots__ = (\n        'status',\n        'title',\n        'description',\n        'headers',\n        'link',\n        'code',\n    )\n\n    def __init__(self, status, title=None, description=None, headers=None,\n                 href=None, href_text=None, code=None):\n        self.status = status\n\n        # TODO(kgriffs): HTTP/2 does away with the \"reason phrase\". Eventually\n        #   we'll probably switch over to making everything code-based to more\n        #   easily support HTTP/2. When that happens, should we continue to\n        #   include the reason phrase in the title?\n        self.title = title or status\n\n        self.description = description\n        self.headers = headers\n        self.code = code\n\n        if href:\n            link = self.link = OrderedDict()\n            link['text'] = (href_text or 'Documentation related to this error')\n            link['href'] = uri.encode(href)\n            link['rel'] = 'help'\n        else:\n            self.link = None\n\n    @property\n    def has_representation(self):\n        return True\n\n    def to_dict(self, obj_type=dict):\n        \"\"\"Returns a basic dictionary representing the error.\n\n        This method can be useful when serializing the error to hash-like\n        media types, such as YAML, JSON, and MessagePack.\n\n        Args:\n            obj_type: A dict-like type that will be used to store the\n                error information (default ``dict``).\n\n        Returns:\n            A dictionary populated with the error's title, description, etc.\n\n        \"\"\"\n\n        assert self.has_representation\n\n        obj = obj_type()\n\n        obj['title'] = self.title\n\n        if self.description is not None:\n            obj['description'] = self.description\n\n        if self.code is not None:\n            obj['code'] = self.code\n\n        if self.link is not None:\n            obj['link'] = self.link\n\n        return obj\n\n    def to_json(self):\n        \"\"\"Returns a pretty-printed JSON representation of the error.\n\n        Returns:\n            A JSON document for the error.\n\n        \"\"\"\n\n        obj = self.to_dict(OrderedDict)\n        return json.dumps(obj, indent=4, separators=(',', ': '),\n                          ensure_ascii=False)\n\n    def to_xml(self):\n        \"\"\"Returns an XML-encoded representation of the error.\n\n        Returns:\n            An XML document for the error.\n\n        \"\"\"\n\n        assert self.has_representation\n\n        error_element = et.Element('error')\n\n        et.SubElement(error_element, 'title').text = self.title\n\n        if self.description is not None:\n            et.SubElement(error_element, 'description').text = self.description\n\n        if self.code is not None:\n            et.SubElement(error_element, 'code').text = str(self.code)\n\n        if self.link is not None:\n            link_element = et.SubElement(error_element, 'link')\n\n            for key in ('text', 'href', 'rel'):\n                et.SubElement(link_element, key).text = self.link[key]\n\n        return (b'<?xml version=\"1.0\" encoding=\"UTF-8\"?>' +\n                et.tostring(error_element, encoding='utf-8'))\n\n\nclass NoRepresentation(object):\n    \"\"\"Mixin for ``HTTPError`` child classes that have no representation.\n\n    This class can be mixed in when inheriting from ``HTTPError``, in order\n    to override the `has_representation` property such that it always\n    returns ``False``. This, in turn, will cause Falcon to return an empty\n    response body to the client.\n\n    You can use this mixin when defining errors that either should not have\n    a body (as dictated by HTTP standards or common practice), or in the\n    case that a detailed error response may leak information to an attacker.\n\n    Note:\n        This mixin class must appear before ``HTTPError`` in the base class\n        list when defining the child; otherwise, it will not override the\n        `has_representation` property as expected.\n\n    \"\"\"\n\n    @property\n    def has_representation(self):\n        return False\n\n\nclass OptionalRepresentation(object):\n    \"\"\"Mixin for ``HTTPError`` child classes that may have a representation.\n\n    This class can be mixed in when inheriting from ``HTTPError`` in order\n    to override the `has_representation` property, such that it will\n    return ``False`` when the error instance has no description\n    (i.e., the `description` kwarg was not set).\n\n    You can use this mixin when defining errors that do not include\n    a body in the HTTP response by default, serializing details only when\n    the web developer provides a description of the error.\n\n    Note:\n        This mixin class must appear before ``HTTPError`` in the base class\n        list when defining the child; otherwise, it will not override the\n        `has_representation` property as expected.\n\n    \"\"\"\n    @property\n    def has_representation(self):\n        return super(OptionalRepresentation, self).description is not None\n", "path": "falcon/http_error.py"}]}