title: Zend Framework Application - Showing 404 Error Pages / Generic Error Pages in Production Mode and showing Exceptions in Development Mode
body: <p>My goal is to achieve the following;
  in any environment, Production, Testing or Development, the application can have 2 modes: Production Mode and Debug Mode.</p>
  
  <p>Currently, I have it setup so that the config.ini has this setting. No issues with that.</p>
  
  <p>The problem comes when I want to achieve the following:
  If the Production Mode is set, I only want to show a custom error page, one with a 404 message if the Controller / Action cannot be found or one with a Generic Error message if a different type of error occurred (exception thrown, connection error, etc). I also need to log the exception where possible to a log/text file.
  If the Debug Mode is set, all I want to see is the Exception that occurred.</p>
  
  <p>I've tried various methods, but I seem to have hit a dead end.
  I've tried using the ErrorHandler Plugin but it just show a blank page when an exception occurrs.
  I've tried using a custom Plugin just to handle 404 errors, doesn't really work because it conflicts with my Authentication Plugin. Tried without the Authentication Plugin, but then it gives issues because of my usage of Modules (just 1 actually, for Admin).</p>
  
  <p>After trying various other things and combinations of them, I can't seem to figure out a way to achieve this.</p>
  
  <p>I would greatly appreciate if anybody can shed some light as to how best to get the desired result.</p>
  
  <p>I also have some assumptions that I would like clarified if I may. They are:</p>
  
  <pre><code>$oFrontController-&gt;throwExceptions(false);
  </code></pre>
  
  <p>Must be set to false in order for the ErrorHandler Plugin to work. Is this correct?</p>
  
  <pre><code>try {
  $oFrontController-&gt;dispatch();
  } catch (Exception $oException) {
  ...
  }
  </code></pre>
  
  <p>I have the above code to catch Exceptions thrown and log them, but as mentioned above, doesn't seem to do the job (works fine when I'm not using the ErrorHandler though, by setting <em>$oFrontController->throwExceptions(true);</em>).</p>
  
  <p>What's the best way to handle Authentication? I currently have it set up as a Plugin, that sets up the 'resource' based on the module/controller and checks with a ACL class so as whether to give access or not. I've seen some examples where the ACL portion is separate on a controller basis. Would it be more sensible to have the Authentication as a Model that gets called at the initialisation of the controller and checks with it's respective set of permissions if the action should be allowed or not? (I ask this mainly because of the conflict that arose when trying to do error pages with the Authentication to see what alternatives are available)</p>
  
  <p>Thank you for any help that you can give me on this matter. Thank you.</p>