Improve reporting of SMTP exception

This commit is contained in:
Finn Stutzenstein 2020-10-23 07:22:56 +02:00
parent 7277a1bb01
commit 1dd86a29be
No known key found for this signature in database
GPG Key ID: 9042F605C6324654

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 = []