# Custom 500 error handler still displaying default error text

**URL:** <https://www.ruby-forum.com/t/custom-500-error-handler-still-displaying-default-error-text/65732>\
**Category:** Rails\
**Created:** [August 21, 2006, 12:31am UTC](https://www.ruby-forum.com/t/custom-500-error-handler-still-displaying-default-error-text/65732 "2006-08-21T00:31:44Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![folke](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/a9a28c/32.png) [@folke](https://www.ruby-forum.com/u/folke)\
**Post date:** [August 21, 2006, 12:31am UTC](https://www.ruby-forum.com/t/custom-500-error-handler-still-displaying-default-error-text/65732/1 "2006-08-21T00:31:44Z")

</div>

I’ve overridden the default error handling mechanism with a custom  
error handler library that’s included in environment.rb:

* * *

## class ActionController::Base def rescue\_action\_in\_public(exception) case exception when ActionController::UnknownAction then render(:file =\> “#{RAILS\_ROOT}/public/404.html”, :status =\> “404 Not Found”) else render(:file =\> “#{RAILS\_ROOT}/public/500.html”, :status =\> “500 Error”) end end end

This works fine, and my custom error message gets displayed. However,  
before it in the source of the html page, this is still being inserted:

Status: 500 Internal Server Error  
Content-Type: text/html

How do I turn that off and display just the custom error page?

Thanks!

–  
- Adam

\*\* Expert Technical Project and Business Management  
\*\*\*\* System Performance Analysis and Architecture  
\*\*\*\*\*\* [[http://www.adamfields.com](http://www.adamfields.com) ]

[[Adam Fields (weblog) - - entertaining hundreds of millions of eyeball atoms every day](http://www.aquick.org/blog) ] … Blog  
[[Adam Fields Resume](http://www.adamfields.com/resume.html) ]… Experience  
[[Adam Fields | Flickr](http://www.flickr.com/photos/fields) ] … Photos  
[[http://www.aquicki.com/wiki](http://www.aquicki.com/wiki) ]…Wiki

---

<div class="post-metadata">

**Author:** ![folke](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/a9a28c/32.png) [@folke](https://www.ruby-forum.com/u/folke)\
**Post date:** [May 24, 2007, 10:27pm UTC](https://www.ruby-forum.com/t/custom-500-error-handler-still-displaying-default-error-text/65732/2 "2007-05-24T22:27:19Z")

</div>

Adam/All,

Did you work this out / know how to fix this? I’m seeing the same thing  
here (i.e. want to stop that text at the top of the page coming in, it’s  
as  
if it’s part of the HTTP 500 error message process that perhaps the  
browser  
puts in there?)

Question = How to stop the the “Status: 500 Internal Server Error…”  
message  
being inserted mysteriously at the top of the 500.html page? (or do I  
have  
to redirect to a rails action/view for errors to solve this? (guess  
this  
won’t be very good if rails itself is the issue and is not working - or  
perhaps do this for exception you catch and leave the 500 error  
mechanism  
unchanged?)

Regards  
Greg

---

<div class="post-metadata">

**Author:** ![folke](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/a9a28c/32.png) [@folke](https://www.ruby-forum.com/u/folke)\
**Post date:** [September 12, 2007, 12:03am UTC](https://www.ruby-forum.com/t/custom-500-error-handler-still-displaying-default-error-text/65732/3 "2007-09-12T00:03:17Z")

</div>

Has anyone figured out this problem?

I noticed that it occurs with the default 500.html display as well.

Greg H. wrote:

> Adam/All,
> 
> Did you work this out / know how to fix this? I’m seeing the same thing  
> here (i.e. want to stop that text at the top of the page coming in, it’s  
> as  
> if it’s part of the HTTP 500 error message process that perhaps the  
> browser  
> puts in there?)
> 
> Question = How to stop the the “Status: 500 Internal Server Error…”  
> message  
> being inserted mysteriously at the top of the 500.html page? (or do I  
> have  
> to redirect to a rails action/view for errors to solve this? (guess  
> this  
> won’t be very good if rails itself is the issue and is not working - or  
> perhaps do this for exception you catch and leave the 500 error  
> mechanism  
> unchanged?)
> 
> Regards  
> Greg
