Answers.Body: <p>If I'm understanding your question correctly, then you get that behavior by default.</p>
  <p>If you:</p>
  <pre><code>throw new \Exception('Uh oh.');
  </code></pre>
  <p>Then you'll get the same error handling layout and logic that Craft uses.</p>
  <p>You can <a href="https://craftcms.stackexchange.com/questions/478/render-generic-message-error-template-from-plugin/483#483">read here</a> for more information on how that works.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-11-04T06:59:45.830Z
Answers.Text: ... I don't even know why I just didn't try this. Cheers Brad :)
Answers.UserDisplayName: naboovalley
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-04-05T14:05:29.057Z
Answers.Text: Minor note: `throw new Exception('Uh oh.');` might not work if you're inside your own class that extends something else. Add a backslash before Exception to read from "root". `throw new \Exception('Uh oh.');`
Answers.UserDisplayName: InanisAtheos
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2014-11-03T17:27:09.797Z
Answers.LastActivityDate: 2022-04-06T21:00:11.363Z
Answers.LastEditDate: 2022-04-06T21:00:11.363Z
Answers.UserDisplayName: Brad Bell
Body: <p>Is it possible for me to use the default Craft error-handling/exception-throwing/debug-showing template layout for my own plugin? Let's say something goes wrong and I want to show that to the user in the same style as any other "code related error" for my Plugin.</p>
  
  <p>Could/how would I achieve this?</p>
  
Tags: <plugin-development>
Title: Use default Craft error/exception layout in Plugin
ThreadText: # Use default Craft error/exception layout in Plugin
  
  (Asked by: username_0 on 2014-11-03)
  
  Is it possible for me to use the default Craft error-handling/exception-throwing/debug-showing template layout for my own plugin? Let's say something goes wrong and I want to show that to the user in the same style as any other "code related error" for my Plugin.
  
  Could/how would I achieve this?
  
  **Tags:** plugin-development
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2014-11-03. Score: 2 | Accepted answer
  
  If I'm understanding your question correctly, then you get that behavior by default.
  
  If you:
  
  ```
  throw new \Exception('Uh oh.');
  
  ```
  
  Then you'll get the same error handling layout and logic that Craft uses.
  
  You can [read here](https://craftcms.stackexchange.com/questions/478/render-generic-message-error-template-from-plugin/483#483) for more information on how that works.
  
  > **Comments:**
  > **username_0**: ... I don't even know why I just didn't try this. Cheers username_1 :)  
  > **username_2**: Minor note: `throw new Exception('Uh oh.');` might not work if you're inside your own class that extends something else. Add a backslash before Exception to read from "root". `throw new \Exception('Uh oh.');`  
  
  ---
  
  