Topic: How to show ALL exceptions to production user?

Does someone know what to set so that ALL exceptions are shown (to user)
when in production mode? I would like the exception to show exactly as
it does in development mode.   I have the following config value set:

config.action_controller.consider_all_requests_local = true

If a rails error occurs, e.g. a call to a method
that doesn't exist, the exception is trapped and the traceback is
displayed to the user.

However if my "raise" is hit the exception only goes to the log.

Here is my code in a controller:

  match = /[\x80-\xff]/ =~ @item.description
  if ! match.nil?
    raise "Bad character(s) in description: "
  end


Here is the exception from the log:


RuntimeError (Bad character(s) in description: )
    /app/controllers/items_controller.rb:439:in `process_form_data'
    /app/controllers/items_controller.rb:563:in `update'
    /usr/lib/ruby/gems/1.8/gems/actionpack-1.11.0/lib/action_controller/
base.rb:841:in `send'
    /usr/lib/ruby/gems/1.8/gems/actionpack-1.11.0/lib/action_controller/
base.rb:841:in `perform_action_without_filters'
    /usr/lib/ruby/gems/1.8/gems/actionpack-1.11.0/lib/action_controller/
filters.rb:332:in `perform_action_without_benchmark'
    /usr/lib/ruby/gems/1.8/gems/actionpack-1.11.0/lib/action_controller/
benchmarking.rb:69:in `perform_action_without_rescue'
    /usr/lib/ruby/gems/1.8/gems/actionpack-1.11.0/lib/action_controller/
benchmarking.rb:69:in `measure'
    /usr/lib/ruby/gems/1.8/gems/actionpack-1.11.0/lib/action_controller/
benchmarking.rb:69:in `perform_action_without_rescue'
    /usr/lib/ruby/gems/1.8/gems/actionpack-1.11.0/lib/action_controller/
rescue.rb:82:in `perform_action'
    /usr/lib/ruby/gems/1.8/gems/actionpack-1.11.0/lib/action_controller/
base.rb:365:in `send'
    /usr/lib/ruby/gems/1.8/gems/actionpack-1.11.0/lib/action_controller/
base.rb:365:in `process_without_session_management_support'
    /usr/lib/ruby/gems/1.8/gems/actionpack-1.11.0/lib/action_controller/
session_management.rb:116:in `process'
    /usr/lib/ruby/gems/1.8/gems/rails-0.14.3/lib/dispatcher.rb:38:in
`dispatch'
    /usr/lib/ruby/gems/1.8/gems/rails-0.14.3/lib/fcgi_handler.rb:141:in
`process_request'
    /usr/lib/ruby/gems/1.8/gems/rails-0.14.3/lib/fcgi_handler.rb:53:in
`process!'
    /usr/lib/ruby/gems/1.8/gems/rails-0.14.3/lib/fcgi_handler.rb:52:in
`each_cgi'
    /usr/lib/ruby/gems/1.8/gems/fcgi-0.8.6.1/./fcgi.rb:597:in `each'
    /usr/lib/ruby/gems/1.8/gems/fcgi-0.8.6.1/./fcgi.rb:597:in `each_cgi'
    /usr/lib/ruby/gems/1.8/gems/rails-0.14.3/lib/fcgi_handler.rb:52:in
`process!'
    /usr/lib/ruby/gems/1.8/gems/rails-0.14.3/lib/fcgi_handler.rb:22:in
`process!'
    /Library/WebServer/Documents/Store/Inventory/public/dispatch.fcgi:24


Rendering /usr/lib/ruby/gems/1.8/gems/actionpack-1.11.0/lib/
action_controller/templates/rescues/layout.rhtml (500 Internal Error)


Richard
RogueWaveMarine.com

Re: How to show ALL exceptions to production user?

Hmm, that should work.

You could put the following method in your application controller and handle the exception manually.

  def rescue_action(exception)
    # do something
    super(exception)
  end