fix(ux): show email account name in error title if available (#35088)
This commit is contained in:
parent
da92e7cd36
commit
046b4fa307
1 changed files with 11 additions and 4 deletions
|
|
@ -95,7 +95,7 @@ class SMTPServer:
|
|||
return self._session
|
||||
|
||||
except smtplib.SMTPAuthenticationError:
|
||||
self.throw_invalid_credentials_exception()
|
||||
self.throw_invalid_credentials_exception(email_account=self.email_account)
|
||||
|
||||
except OSError as e:
|
||||
# Invalid mail server -- due to refusing connection
|
||||
|
|
@ -128,10 +128,17 @@ class SMTPServer:
|
|||
self._session.quit()
|
||||
|
||||
@classmethod
|
||||
def throw_invalid_credentials_exception(cls):
|
||||
def throw_invalid_credentials_exception(cls, email_account=None):
|
||||
original_exception = get_traceback() or "\n"
|
||||
error_message = (
|
||||
_("Please check your email login credentials.") + " " + original_exception.splitlines()[-1]
|
||||
)
|
||||
error_title = _("Invalid Credentials")
|
||||
if email_account:
|
||||
error_title = _("Invalid Credentials for Email Account: {0}").format(email_account)
|
||||
|
||||
frappe.throw(
|
||||
_("Please check your email login credentials.") + " " + original_exception.splitlines()[-1],
|
||||
title=_("Invalid Credentials"),
|
||||
error_message,
|
||||
title=error_title,
|
||||
exc=InvalidEmailCredentials,
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue