Skip to content

Commit 11297cc

Browse files
committed
doc: document printing out HTTP error details
Relates #105
1 parent fa7ac90 commit 11297cc

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

docs/usage/advanced.rst

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,19 @@ Error handling
4545
--------------
4646

4747
PyOData returns *HttpError* when the response code does not match the expected
48-
code. Basically the exception is raised for all status codes >= 400.
48+
code. Basically the exception is raised for all status codes >= 400 and its
49+
instances have the property response which holds return value of the library
50+
making HTTP requests.
51+
52+
For example, the following code show how to print out error details if
53+
Python Requests is used as the HTTP communication library.
54+
55+
.. code-block:: python
56+
57+
try:
58+
new_data = create_request.execute()
59+
except pyodata.exceptions.HttpError as ex:
60+
print(ex.response.text)
4961
5062
In the case you know the implementation of back-end part and you want to show
5163
accurate errors reported by your service, you can replace *HttpError* by your

0 commit comments

Comments
 (0)