Skip to content

Commit

Permalink
[BF] Better error handling for dup alias - fixes #260
Browse files Browse the repository at this point in the history
  • Loading branch information
barryo committed May 16, 2020
1 parent c410c1b commit fedf85b
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion application/controllers/MailboxController.php
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,18 @@ public function addAction()
);

$this->notify( 'mailbox', 'add', 'addPreflush', $this );
$this->getD2EM()->flush();

try {
$this->getD2EM()->flush();
} catch( Doctrine\DBAL\Exception\UniqueConstraintViolationException $e ) {
if( strpos( $e->getMessage(), 'occurred while executing \'INSERT INTO alias' ) > 0 ) {
$this->addMessage(_("An alias already exists for the mailbox you are trying to create. Please delete the alias first."), OSS_Message::ERROR);
return;
}
throw $e;
}


$this->notify( 'mailbox', 'add', 'addPostflush', $this, [ 'options' => $this->_options ] );

if( $form->getValue( 'welcome_email' ) )
Expand Down

0 comments on commit fedf85b

Please sign in to comment.