src/InfinityBase/Service/AbstractService.php
protected function save($successMessage, $failureMessage)
    {
        try {
            $this->getEntityManager()->flush();
            $this->addMessage($successMessage, FlashMessenger::NAMESPACE_SUCCESS);
            return true;
        } catch (\Exception $e) {
            $this->addMessage($failureMessage, FlashMessenger::NAMESPACE_ERROR);

            // Check exception type
            if ($e instanceof \Doctrine\DBAL\DBALException) {
                $previous = $e->getPrevious();
                if ($previous instanceof \Doctrine\DBAL\Driver\Mysqli\MysqliException) {

                    // Check exception type
                    switch ($previous->getCode()) {
                        case 1062:
                            $this->addMessage(
                                    'You are using details that already exist.', 'error'
                            );
                            return false;
                    }
                }
            }

            /**
             * TO BE REMOVED -- BELOW
             */
            throw new \Exception('You are seeing this because this error needs to be properly handled.', 0, $e);
            /**
             * TO BE REMOVED -- ABOVE
             */
            return false;
        }
    }
protected function save($successMessage, $failureMessage)
    {
        try {
            $this->getEntityManager()->flush();
            $this->addMessage($successMessage, FlashMessenger::NAMESPACE_SUCCESS);
            return true;
        } catch (\Exception $e) {
            $this->addMessage($failureMessage, FlashMessenger::NAMESPACE_ERROR);

            // Check exception type
            if ($e instanceof \Doctrine\DBAL\DBALException) {
                $previous = $e->getPrevious();
                if ($previous instanceof \Doctrine\DBAL\Driver\Mysqli\MysqliException) {

                    // Check exception type
                    switch ($previous->getCode()) {
                        case 1062:
                            $this->addMessage(
                                    'You are using details that already exist.', 'error'
                            );
                            return false;
                    }
                }
            }

            /**
             * TO BE REMOVED -- BELOW
             */
            throw new \Exception('You are seeing this because this error needs to be properly handled.', 0, $e);
            /**
             * TO BE REMOVED -- ABOVE
             */
            return false;
        }
    }
protected function save ( $ successMessage , $ failureMessage ) { try { $ this -> getEntityManager ( ) -> flush ( ) ; $ this -> addMessage ( $ successMessage , FlashMessenger :: NAMESPACE_SUCCESS ) ; return true ; } catch ( \ Exception $ e ) { $ this -> addMessage ( $ failureMessage , FlashMessenger :: NAMESPACE_ERROR ) ; // Check exception type if ( $ e instanceof \ Doctrine \ DBAL \ DBALException ) { $ previous = $ e -> getPrevious ( ) ; if ( $ previous instanceof \ Doctrine \ DBAL \ Driver \ Mysqli \ MysqliException ) { // Check exception type switch ( $ previous -> getCode ( ) ) { case 1062 : $ this -> addMessage ( 'You are using details that already exist.' , 'error' ) ; return false ; } } } /**
             * TO BE REMOVED -- BELOW
             */ throw new \ Exception ( 'You are seeing this because this error needs to be properly handled.' , 0 , $ e ) ; /**
             * TO BE REMOVED -- ABOVE
             */ return false ; } }
Flush the entityManager and handle errors

@return boolean
Flush the entityManager and handle errors