Skip to content

Commit d3cd8ce

Browse files
committed
update errors docs
1 parent adb44c1 commit d3cd8ce

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

docs/additional_info/exception_handling.rst

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,23 @@ To handle an exception you would do the following:
2626

2727
.. code-block:: python
2828
29-
try:
30-
client.project('invalid_id')
31-
except lokalise.errors.NotFound as err:
32-
print(err.message)
33-
print(err.status_code)
29+
try:
30+
project = client.project("invalid")
31+
except errors.BadRequest as e:
32+
print("=== Lokalise API Error ===")
33+
print("Type:", type(e).__name__)
34+
print("Status code:", e.status_code)
35+
print("Message:", e.message)
36+
print("Headers:", e.headers)
37+
print("Raw text:", e.raw_text)
38+
39+
if e.parsed:
40+
print("--- Parsed error ---")
41+
print("Parsed status:", e.parsed.status)
42+
print("Parsed message:", e.parsed.message)
43+
print("Parsed reason:", e.parsed.reason)
44+
print("Parsed code:", e.parsed.code)
45+
print("Parsed details:", e.parsed.details)
3446
3547
Rate limits
3648
-----------

0 commit comments

Comments
 (0)