Merge pull request #5656 from FinnStutzenstein/SmtpException

Improve reporting of SMTP exception
This commit is contained in:
Finn Stutzenstein 2020-10-28 08:18:43 +01:00 committed by GitHub
commit d4577ed8aa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -515,7 +515,11 @@ class UserViewSet(ModelViewSet):
}
)
except smtplib.SMTPException as err:
raise ValidationError({"detail": f"{err.errno}: {err.strerror}"})
if err.errno and err.strerror:
detail = f"{err.errno}: {err.strerror}"
else:
detail = str(err)
raise ValidationError({"detail": detail})
success_users = []
user_pks_without_email = []