Render generic message/error template from plugin Basically, I'm trying to emulate show_error from EE/CI: http://ellislab.com/codeigniter/user-guide/general/errors.html

I want to just use the generic Craft error template (/craft/app/templates/error.html), like what happens if you have a DB connection error, and have it serve a 500.

This is from with a plugin controller.

What's the best way to do that?
I'm not familiar with EE's show_error, but a plugin's error template logic is identical to the logic that Craft uses to determine what to display.

From your plugin, if you:

throw new HttpException($statusCode, $optionalMessage)


Where $statusCode is 404 or 400, or any proper http status code, Craft will load the corresponding 404.html, 400.html, etc. from the craft/app/templates folder displaying the optional message, or the more generic message supplied in the template if no optional one is provided.

However, if you have supplied your own 404, 400, etc. from your own craft/templates folder, Craft will display that one instead of the one it provides so you can customize these errors for your site.

If you:

throw new Exception($optionalMessage)


while devMode is enabled, then Craft will load exception.html which will display the full error long with stack trace to help in debugging.  If devMode is not enabled, it will display the more generic error.html.

Craft specifically checks for database connection errors and will display the error.html template while setting a 500 status code.