Answers.Body: <p>Just re-throw the exception and pretend like nothing ever happened...</p>
  
  <pre><code>try
  {
      // Some code which might produce an error
  }
  catch (\Exception $e)
  {
      if (craft()-&gt;request-&gt;isCpRequest()) {
          // Do something with $e-&gt;getMessage()
      } else {
          // Nothing to see here...
          throw $e;
      }
  }
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-04-17T22:03:35.013Z
Answers.Text: Brilliant, thanks Brad! Worked like a charm!
Answers.UserDisplayName: Lindsey D
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-04-17T22:01:08.670Z
Answers.LastActivityDate: 2015-04-17T22:01:08.670Z
Answers.UserDisplayName: Brad Bell
Body: <p>In my plugin, I'd like to catch errors when they appear in the control panel, so I can handle them differently. However, from the front-end, I'd like to keep the <em>default</em> Craft-style handling of error messages.</p>
  
  
  
  <pre class="lang-php prettyprint-override"><code>try
  {
      // Some code which might produce an error
  }
  catch (\Exception $e)
  {
      if (craft()-&gt;request-&gt;isCpRequest()) {
          // Do something with $e-&gt;getMessage()
      } else {
          // Use default Craft error handling
      }
  }
  </code></pre>
  
  <p>All of that is working for me, just trying to sort out how to do this part...</p>
  
  <pre class="lang-php prettyprint-override"><code>// Use default Craft error handling
  </code></pre>
  
  <p><strong>How can I get my error handling to just go back to what Craft was doing by default?</strong> I want to make sure my errors still appear in devMode per usual.</p>
  
Tags: <plugin-development><error><error-handling>
Title: Return to default error handling
ThreadText: # Return to default error handling
  
  (Asked by: username_0 on 2015-04-17)
  
  In my plugin, I'd like to catch errors when they appear in the control panel, so I can handle them differently. However, from the front-end, I'd like to keep the *default* Craft-style handling of error messages.
  
  ```php
  try
  {
      // Some code which might produce an error
  }
  catch (\Exception $e)
  {
      if (craft()->request->isCpRequest()) {
          // Do something with $e->getMessage()
      } else {
          // Use default Craft error handling
      }
  }
  
  ```
  
  All of that is working for me, just trying to sort out how to do this part...
  
  ```php
  // Use default Craft error handling
  
  ```
  
  **How can I get my error handling to just go back to what Craft was doing by default?** I want to make sure my errors still appear in devMode per usual.
  
  **Tags:** plugin-development, error, error-handling
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2015-04-17. Score: 1 | Accepted answer
  
  Just re-throw the exception and pretend like nothing ever happened...
  
  ```
  try
  {
      // Some code which might produce an error
  }
  catch (\Exception $e)
  {
      if (craft()->request->isCpRequest()) {
          // Do something with $e->getMessage()
      } else {
          // Nothing to see here...
          throw $e;
      }
  }
  
  ```
  
  > **Comments:**
  > **username_0**: Brilliant, thanks username_1! Worked like a charm!  
  
  ---
  
  