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?

1 Answer 1


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 for more information on how that works.

  • ... I don't even know why I just didn't try this. Cheers Brad :) Nov 4, 2014 at 6:59
  • 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.'); Apr 5 at 14:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.