How to render my own error pages correctly?

Hi there,

I am trying to get my own error pages (404 for example) displayed

I raise an error in my controller:
raise, “Bad thing.”

Therefore I defined:
class MyException < Exception

Furthermore I catch that in application.rb:
def rescue_action_in_public(exception)
case exception
when MyException
logger.error(“404 displayed”)
render :file =>
:status => “404”, :layout => false

So far, so good. I get my page displayed. BUT everytime my application
layout (application.rhtml) gets rendered too! Look, I’ve set “:layout =>

The problem is, that I can not get a really 404 error with this. I alws
get 200 error. I think it is beacause the 404_myerror.html is rendered
within this application.rhtml. I can verify this via console:

app.get “/produceerror/bad”
=> 200

(in my action “bad” i raise the 404)

What do you think? This Exception handling for errors is a bit sucky :wink: