Skip to content

Commit

Permalink
#763 update error handing documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkingserious committed May 21, 2019
1 parent 9c1d254 commit 472c845
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 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

To read the error message returned by Twilio SendGrid's API in Python 2.X:
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 Twilio 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

0 comments on commit 472c845

Please sign in to comment.