I'm looking for a way to test if a connection is working or not with Doctrine 2.

As in my application users can change by themselves the information connections, I want to check if the user has entered the right login and password.

How can I do that?

I tried to put this code into a try/catch block :

```php
try{
    $entityManager = $this->getEntityManager() ;
    $repository = $entityManager->getRepository('Authentification\Entity\User');
    $userToIdentify = $repository->findOneBy(array('login' => $this->_username, 'password' => $this->_password));
}catch(Exception $e){
    $code = Result::FAILURE ;
    $identity = "unknow" ;
    $messages = array(
       "message" => "Wrong login/password combination",
    ) ;
}

```

The problem is that even if the information connection is correct, I cannot catch the exception.

Otherwise I get the following error :

```html
<b>Fatal error</b>:  Uncaught exception 'Zend\View\Exception\RuntimeException'
  with message 'Zend\View\Renderer\PhpRenderer::render: Unable to render template 
  &quot;layout/layout&quot;; resolver could not resolve to a file' in C:\xampp\htdocs\poemsV3\vendor\zendframework\zendframework\library\Zend\View\Renderer\PhpRenderer.php:451 Stack trace: #0 C:\xampp\htdocs\poemsV3\vendor\zendframework\zendframework\library\Zend\View\View.php(203): Zend\View\Renderer\PhpRenderer-&gt;render(Object(Zend\View\Model\ViewModel)) #1 C:\xampp\htdocs\poemsV3\vendor\zendframework\zendframework\library\Zend\Mvc\View\Http\DefaultRenderingStrategy.php(128): Zend\View\View-&gt;render(Object(Zend\View\Model\ViewModel)) #2 [internal function]: Zend\Mvc\View\Http\DefaultRenderingStrategy-&gt;render(Object(Zend\Mvc\MvcEvent))#3 C:\xampp\htdocs\poemsV3\vendor\zendframework\zendframework\library\Zend\EventManager\EventManager.php(469): call_user_func(Array, Object(Zend\Mvc\MvcEvent))#4 C:\xampp\htdocs\poemsV3\vendor\zendframework\zendframework\library\Zend\EventManager\EventMa in <b>C:\xampp\htdocs\poemsV3\vendor\zendframework\zendframework\library\Zend\View\Renderer\PhpRenderer.php</b> on line <b>451</b><br />

```

Do you have any idea in how I could test if the connection works?

Thank you.