Reputation: 599
I would like to control and embed my send()
calls in a try/except, but I'm not sure of what errors it can produce.
Looking around the SDK, it seems like MailServiceError is the one, but not sure since I don't know how to test an error like that.
Can anyone confirm this?
Upvotes: 0
Views: 123
Reputation: 8471
Here are the exceptions that can be thrown by a call to send(): https://developers.google.com/appengine/docs/python/mail/exceptions
Here's an example of how you could catch these:
from google3.apphosting.api import mail
# other code to create 'message' here
try:
message.send()
except mail.InvalidSender, e:
# Do something special for an invalid sender error
pass
except mail.Error, e:
# This will catch all the other exceptions in the doc above.
pass
Upvotes: 4