Answers.Body: <p>On a default Craft install if I'm logged out and hit the front-end of the site with purposefully messed up database credentials, I get a nicely styled Craft 404 page if there is no <code>craft/templates/404.html</code> and a front-end 404 page if there is.</p>
  
  <p>I believe the issue is that you've got your own front-end 404 template that's also trying to access the database and it can't.</p>
  
  <p>So basically the first error is thrown (can't access the database), then another error happens (I <em>really</em> can't access the database) when trying to tell you about the first error.</p>
  
  <p>By this point, Yii thinks the error has already been handled, so it falls back to <a href="https://github.com/yiisoft/yii/blob/1.1.15/framework/base/CApplication.php#L924" rel="nofollow">CApplication->displayException()</a>.  I assume in this case, some content header or encoding isn't set properly and you see the garbled ’ character.</p>
  
  <p>So until/if we can think of a way to guard against this scenario, your best bet is to make sure that your 404 template isn't triggering a database call.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-12-03T01:22:56.607Z
Answers.LastActivityDate: 2014-12-03T01:22:56.607Z
Answers.UserDisplayName: Brad Bell
Body: <p>Is it possible to route to a nice "Site is currently offline" error page if there is an issue connecting to the database?</p>
  
  <p>Currently you'll see something like the message below which isn't very customer friendly.</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.") 
  </code></pre>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2014-12-02T17:48:42.963Z
Comments.Text: The part about this that always bugs me the most is the weird non-apostrophe in `canâ€™t`.
Comments.UserDisplayName: Lindsey D
Tags: <database><error-message>
Title: Change message if database error
ThreadText: # Change message if database error
  
  (Asked by: username_0 on 2014-12-02)
  
  Is it possible to route to a nice "Site is currently offline" error page if there is an issue connecting to the database?
  
  Currently you'll see something like the message below which isn't very customer friendly.
  
  ```
  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.") 
  
  ```
  
  **Tags:** database, error-message
  
  > **Comments:**
  > **username_1**: The part about this that always bugs me the most is the weird non-apostrophe in `canâ€™t`.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2014-12-03. Score: 1
  
  On a default Craft install if I'm logged out and hit the front-end of the site with purposefully messed up database credentials, I get a nicely styled Craft 404 page if there is no `craft/templates/404.html` and a front-end 404 page if there is.
  
  I believe the issue is that you've got your own front-end 404 template that's also trying to access the database and it can't.
  
  So basically the first error is thrown (can't access the database), then another error happens (I *really* can't access the database) when trying to tell you about the first error.
  
  By this point, Yii thinks the error has already been handled, so it falls back to [CApplication->displayException()](https://github.com/yiisoft/yii/blob/1.1.15/framework/base/CApplication.php#L924). I assume in this case, some content header or encoding isn't set properly and you see the garbled ’ character.
  
  So until/if we can think of a way to guard against this scenario, your best bet is to make sure that your 404 template isn't triggering a database call.
  
  
  ---
  
  