- $confirm = $this->getConfirmation();
-
- if (!$confirm) {
- $this->showForm(_('No pending confirmation to cancel.'));
- return;
- }
- if ($confirm->address != $sms) {
- $this->showForm(_('That is the wrong confirmation number.'));
- return;
+ try {
+ $confirm = $this->getConfirmation();
+ if ($confirm->address != $sms) {
+ // TRANS: Message given canceling SMS phone number confirmation for the wrong phone number.
+ throw new ClientException(_('That is the wrong confirmation number.'));
+ }
+ } catch (NoResultException $e) {
+ // TRANS: Message given canceling SMS phone number confirmation that is not pending.
+ throw new AlreadyFulfilledException(_('No pending confirmation to cancel.'));