Skip to content

Document the new error handling functionality from python-http-client #442

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

Closed
thinkingserious opened this issue Oct 26, 2017 · 1 comment · Fixed by #481
Closed

Document the new error handling functionality from python-http-client #442

thinkingserious opened this issue Oct 26, 2017 · 1 comment · Fixed by #481
Labels
status: help wanted requesting help from the community

Comments

@thinkingserious
Copy link
Contributor

Issue Summary

Here is a PR that implements the new error handling: sendgrid/python-http-client#17

Here is an example of usage:

import sendgrid
import os
from sendgrid.helpers.mail import *
from python_http_client import exceptions

sg = sendgrid.SendGridAPIClient(apikey=os.environ.get('SENDGRID_API_KEY'))
from_email = Email("dx@sendgrid.com")
to_email = Email("elmer.thomas@sendgrid.com")
subject = "Sending with SendGrid is Fun"
content = Content("text/plain", "and easy to do anywhere, even with Python")
mail = Mail(from_email, subject, to_email, content)
try:
    response = sg.client.mail.send.post(request_body=mail.get())
except exceptions.BadRequestsError as e:
    print(e.body)
    exit()
print(response.status_code)
print(response.body)
print(response.headers)

The examples should go under USE_CASES.md and be referenced from TROUBLESHOOTING.md under error handling.

@thinkingserious thinkingserious added difficulty: medium fix is medium in difficulty hacktoberfest labels Oct 26, 2017
@mbernier mbernier removed difficulty: hard fix is hard in difficulty difficulty: medium fix is medium in difficulty difficulty: very hard fix is very hard in difficulty labels Oct 27, 2017
@mptap
Copy link
Contributor

mptap commented Oct 27, 2017

@mbernier: PR: #481

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: help wanted requesting help from the community
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants