skeleton of error handling

pull/1/head
Andromeda Yelton 2013-06-03 17:18:42 -04:00
parent ad69580b2d
commit 0273a907da
1 changed files with 7 additions and 4 deletions

View File

@ -2480,9 +2480,12 @@ def send_to_kindle(request, kindle_ebook_id):
filehandle = urllib.urlopen(ebook.url)
email = EmailMessage(from_email='kindle@gluejar.com',
to=[request.user.profile.kindle_email])
email.attach(title + '.' + ebook.format, filehandle.read())
email.send()
try:
email = EmailMessage(from_email='kindle@gluejar.com',
to=[request.user.profile.kindle_email])
email.attach(title + '.' + ebook.format, filehandle.read())
email.send()
except SMTPSenderRefused:
return HttpResponse('We can\'t send files bigger than 25MB. please download the file and sideload it to your device.')
return HttpResponse('sent to Kindle')