Answers.Body: <p>DB connection errors are the <strong>only</strong> case where Craft will output the full error even if <a href="http://buildwithcraft.com/help/dev-mode" rel="nofollow">Dev Mode</a> is disabled, because 99.99% of the time those only occur when Craft is not yet installed, and it’s an extremely common issue people run into when installing Craft.</p>
  
  <p>If you really want to prevent those errors from showing up on the front end, you can edit your index.php file so that it catches them, and displays something different:</p>
  
  <pre class="lang-php prettyprint-override"><code>&lt;?php
  
  // Path to your craft/ folder
  $craftPath = '../craft';
  
  // Do not edit below this line
  $path = rtrim($craftPath, '/').'/app/index.php';
  
  if (!is_file($path))
  {
      exit('Could not find your craft/ folder. Please ensure that &lt;strong&gt;&lt;code&gt;$craftPath&lt;/code&gt;&lt;/strong&gt; is set correctly in '.__FILE__);
  }
  
  try
  {
      require_once $path;
  }
  catch (Craft\DbConnectException $e)
  {
      exit('An error occurred.');
  }
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-08-21T13:16:22.823Z
Answers.Text: Thanks. In the end I went with the heavy handed approach of catching all to make sure nothing sneaks through.
  
  I found the DB Exception was only thrown when accessing `domain.com/admin` but I was still getting the original message when accessing `domain.com` as it is throwing a Craft HTTP Exception.
Answers.UserDisplayName: fcb
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-08-20T12:38:50.770Z
Answers.LastActivityDate: 2014-08-20T12:38:50.770Z
Answers.UserDisplayName: Brandon Kelly
Body: <p>Due to a server problem one of our production sites was unable to connect to the DB.</p>
  
  <p>While it was unable to connect the site was outputting the error:</p>
  
  <pre><code>An exception has been thrown during the rendering of a template ("Craft can't connect to the database with the credentials in craft/config/db.php.") in "_layout" at line 10.
  </code></pre>
  
  <p>I'm a little concerned that a production site is outputting this kind of information, is there a way to stop these errors being output?</p>
  
  <p>(The site is currently running Craft Pro 2.1.2561 with dev mode disabled.)</p>
  
  <p>Thanks.</p>
  
Tags: <error-message>
Title: How to stop rendering errors being output in production
ThreadText: # How to stop rendering errors being output in production
  
  (Asked by: username_0 on 2014-08-20)
  
  Due to a server problem one of our production sites was unable to connect to the DB.
  
  While it was unable to connect the site was outputting the error:
  
  ```
  An exception has been thrown during the rendering of a template ("Craft can't connect to the database with the credentials in craft/config/db.php.") in "_layout" at line 10.
  
  ```
  
  I'm a little concerned that a production site is outputting this kind of information, is there a way to stop these errors being output?
  
  (The site is currently running Craft Pro 2.1.2561 with dev mode disabled.)
  
  Thanks.
  
  **Tags:** error-message
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2014-08-20. Score: 3 | Accepted answer
  
  DB connection errors are the **only** case where Craft will output the full error even if [Dev Mode](http://buildwithcraft.com/help/dev-mode) is disabled, because 99.99% of the time those only occur when Craft is not yet installed, and it’s an extremely common issue people run into when installing Craft.
  
  If you really want to prevent those errors from showing up on the front end, you can edit your index.php file so that it catches them, and displays something different:
  
  ```php
  <?php
  
  // Path to your craft/ folder
  $craftPath = '../craft';
  
  // Do not edit below this line
  $path = rtrim($craftPath, '/').'/app/index.php';
  
  if (!is_file($path))
  {
      exit('Could not find your craft/ folder. Please ensure that <strong><code>$craftPath</code></strong> is set correctly in '.__FILE__);
  }
  
  try
  {
      require_once $path;
  }
  catch (Craft\DbConnectException $e)
  {
      exit('An error occurred.');
  }
  
  ```
  
  > **Comments:**
  > **username_0**: Thanks. In the end I went with the heavy handed approach of catching all to make sure nothing sneaks through.  I found the DB Exception was only thrown when accessing `domain.com/admin` but I was still getting the original message when accessing `domain.com` as it is throwing a Craft HTTP Exception.  
  
  ---
  
  