Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated Error Message Section #763

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions TROUBLESHOOTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,25 +32,28 @@ In the first case, SENDGRID_API_KEY is in reference to the name of the environme
<a name="error"></a>
## Error Messages

HTTP exceptions are defined in the [`python_http_client` package](https://github.com/sendgrid/python-http-client/blob/master/python_http_client/exceptions.py).

To read the error message returned by SendGrid's API in Python 2.X:

```python
import urllib2
from python_http_client.exceptions import HTTPError

try:
response = sendgrid_client.send(request_body=mail.get())
except urllib2.HTTPError as e:
print(e.read())
response = sg.client.mail.send.post(request_body=mail.get())
except HTTPError as e:
print e.to_dict
```

To read the error message returned by SendGrid's API in Python 3.X:

```python
import urllib
from python_http_client.exceptions import HTTPError

try:
response = sendgrid_client.send(request_body=mail.get())
except urllib.error.HTTPError as e:
print(e.read())
response = sg.client.mail.send.post(request_body=mail.get())
except HTTPError as e:
print(e.to_dict)
```

<a name="migrating"></a>
Expand Down