Skip to content

Commit

Permalink
Catches exception errors before rendering the form
Browse files Browse the repository at this point in the history
  • Loading branch information
VangelisP committed Jun 18, 2023
1 parent 03ab15f commit 89d1696
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion CRM/Admin/Form/Setting/Smtp.php
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,13 @@ public function setDefaultValues() {
$this->_defaults = $mailingBackend;

if (!empty($this->_defaults['smtpPassword'])) {
$this->_defaults['smtpPassword'] = \Civi::service('crypto.token')->decrypt($this->_defaults['smtpPassword']);
try {
$this->_defaults['smtpPassword'] = \Civi::service('crypto.token')->decrypt($this->_defaults['smtpPassword']);
}
catch (Exception $e) {
Civi::log()->error($e->getMessage());
CRM_Core_Session::setStatus(ts('Unable to retrieve the encrypted password. Please check your configured encryption keys. The error message is: %1', [1 => $e->getMessage()]), ts("Encryption key error"), "error");
}
}
}
else {
Expand Down

0 comments on commit 89d1696

Please sign in to comment.