Skip to content

Commit

Permalink
CIWEMB-491: Replace the membership status calculation error with more…
Browse files Browse the repository at this point in the history
… readable content when switching membership type
  • Loading branch information
omarabuhussein committed Nov 4, 2023
1 parent b8ac2d2 commit d02c5e0
Showing 1 changed file with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,10 @@ public function postProcess() {
);
}
catch (Exception $e) {
$errorMessage = $e->getMessage();
$this->replaceExceptionMessagesWithHumanReadableContent($errorMessage);
CRM_Core_Session::setStatus(
ts('The membership type could not be changed: ') . $e->getMessage(),
ts('The membership type could not be changed. Error reason: ') . $e->getMessage(),
ts('Changing Membership Type'),
'error'
);
Expand All @@ -140,4 +142,18 @@ private function getOneOffFeeParams($submittedValues) {
];
}

/**
* Replaces some of the exception messages thrown
* when submitting this form with more readable
* content.
*
* @param string $errorMessage
* @return void
*/
private function replaceExceptionMessagesWithHumanReadableContent(&$errorMessage) {
if (strpos($errorMessage, 'The membership cannot be saved because the status cannot be calculated') !== FALSE) {
$errorMessage = 'There is no valid membership status available for the given membership dates.';
}
}

}

0 comments on commit d02c5e0

Please sign in to comment.