Skip to content

Commit

Permalink
docs: remove leading spaces on error handling example (#1032)
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkingserious authored Jan 5, 2022
1 parent 76c5f46 commit b729f40
Showing 1 changed file with 19 additions and 19 deletions.
38 changes: 19 additions & 19 deletions use_cases/error_handling.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,24 @@ Please see [here](https://github.com/sendgrid/python-http-client/blob/HEAD/pytho
There are also email specific exceptions located [here](../sendgrid/helpers/mail/exceptions.py)

```python
import os
from sendgrid import SendGridAPIClient
from sendgrid.helpers.mail import (From, To, Subject, PlainTextContent, HtmlContent, Mail)
from python_http_client import exceptions
import os
from sendgrid import SendGridAPIClient
from sendgrid.helpers.mail import (From, To, Subject, PlainTextContent, HtmlContent, Mail)
from python_http_client import exceptions

sendgrid_client = SendGridAPIClient(os.environ.get('SENDGRID_API_KEY'))
from_email = From("[email protected]")
to_email = To("[email protected]")
subject = Subject("Sending with Twilio SendGrid is Fun")
plain_text_content = PlainTextContent("and easy to do anywhere, even with Python")
html_content = HtmlContent("<strong>and easy to do anywhere, even with Python</strong>")
message = Mail(from_email, to_email, subject, plain_text_content, html_content)
try:
response = sendgrid_client.send(message)
print(response.status_code)
print(response.body)
print(response.headers)
except exceptions.BadRequestsError as e:
print(e.body)
exit()
sendgrid_client = SendGridAPIClient(os.environ.get('SENDGRID_API_KEY'))
from_email = From("[email protected]")
to_email = To("[email protected]")
subject = Subject("Sending with Twilio SendGrid is Fun")
plain_text_content = PlainTextContent("and easy to do anywhere, even with Python")
html_content = HtmlContent("<strong>and easy to do anywhere, even with Python</strong>")
message = Mail(from_email, to_email, subject, plain_text_content, html_content)
try:
response = sendgrid_client.send(message)
print(response.status_code)
print(response.body)
print(response.headers)
except exceptions.BadRequestsError as e:
print(e.body)
exit()
```

0 comments on commit b729f40

Please sign in to comment.