# Cannot catch ActionController exception

**URL:** <https://discuss.rubyonrails.org/t/cannot-catch-actioncontroller-exception/3486>\
**Category:** rubyonrails-talk\
**Created:** [October 23, 2006, 11:44pm UTC](https://discuss.rubyonrails.org/t/cannot-catch-actioncontroller-exception/3486 "2006-10-23T23:44:24Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![joman](https://avatars.discourse-cdn.com/v4/letter/j/2bfe46/32.png) [@joman](https://discuss.rubyonrails.org/u/joman)\
**Post date:** [October 23, 2006, 11:44pm UTC](https://discuss.rubyonrails.org/t/cannot-catch-actioncontroller-exception/3486/1 "2006-10-23T23:44:24Z")

</div>

Hi,

I am running ruby 1.8.2 (ruby 1.8.2 (2005-04-11) [i386-linux])

I cannot catch the ActionController::RedirectBackError exception.

My code is:

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;redirect\_to :back &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;rescue ActionController::RedirectBackError &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;redirect\_to :action =\> 'index' &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end

When the exception is raised I get the following error:

NameError in Release managementController#new

uninitialized constant RedirectBackError

RAILS\_ROOT: ./script/../config/.. Application Trace | Framework Trace | Full Trace

/usr/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active\_support/dependencies.rb:123:in `const_missing' #{RAILS_ROOT}/app/controllers/release_management_controller.rb:821:in `new'

/usr/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active\_support/dependencies.rb:123:in `const_missing' /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/base.rb:941:in `send' /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action\_controller/base.rb:941:in `perform_action_without_filters' /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/filters.rb:368:in `perform\_action\_without\_benchmark' /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action\_controller/benchmarking.rb:69:in `perform_action_without_rescue' /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/benchmarking.rb:69:in `measure' /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action\_controller/benchmarking.rb:69:in `perform_action_without_rescue' /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/rescue.rb:82:in `perform\_action' /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action\_controller/base.rb:408:in `send' /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/base.rb:408:in `process\_without\_filters' /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action\_controller/filters.rb:377:in `process_without_session_management_support' /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/session_management.rb:117:in `process' /usr/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/dispatcher.rb:38:in `dispatch' /usr/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/webrick_server.rb:115:in `handle\_dispatch' /usr/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/webrick\_server.rb:81:in `service' /usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service' /usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run' /usr/lib/ruby/1.8/webrick/server.rb:172:in `start\_thread' /usr/lib/ruby/1.8/webrick/server.rb:161:in `start' /usr/lib/ruby/1.8/webrick/server.rb:161:in `start\_thread' /usr/lib/ruby/1.8/webrick/server.rb:95:in `start' /usr/lib/ruby/1.8/webrick/server.rb:92:in `each' /usr/lib/ruby/1.8/webrick/server.rb:92:in `start' /usr/lib/ruby/1.8/webrick/server.rb:82:in `start' /usr/lib/ruby/1.8/webrick/server.rb:82:in `start' /usr/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/webrick_server.rb:67:in `dispatch' script/server:49

/usr/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active\_support/dependencies.rb:123:in `const_missing' #{RAILS_ROOT}/app/controllers/release_management_controller.rb:821:in `new' /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action\_controller/base.rb:941:in `send' /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/base.rb:941:in `perform\_action\_without\_filters' /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action\_controller/filters.rb:368:in `perform_action_without_benchmark' /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/benchmarking.rb:69:in `perform\_action\_without\_rescue' /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action\_controller/benchmarking.rb:69:in `measure' /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/benchmarking.rb:69:in `perform\_action\_without\_rescue' /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action\_controller/rescue.rb:82:in `perform_action' /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/base.rb:408:in `send' /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action\_controller/base.rb:408:in `process_without_filters' /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/filters.rb:377:in `process\_without\_session\_management\_support' /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action\_controller/session\_management.rb:117:in `process' /usr/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/dispatcher.rb:38:in `dispatch' /usr/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/webrick\_server.rb:115:in `handle_dispatch' /usr/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/webrick_server.rb:81:in `service' /usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service' /usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run' /usr/lib/ruby/1.8/webrick/server.rb:172:in `start_thread' /usr/lib/ruby/1.8/webrick/server.rb:161:in `start' /usr/lib/ruby/1.8/webrick/server.rb:161:in `start_thread' /usr/lib/ruby/1.8/webrick/server.rb:95:in `start' /usr/lib/ruby/1.8/webrick/server.rb:92:in `each' /usr/lib/ruby/1.8/webrick/server.rb:92:in `start' /usr/lib/ruby/1.8/webrick/server.rb:82:in `start' /usr/lib/ruby/1.8/webrick/server.rb:82:in `start' /usr/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/webrick\_server.rb:67:in `dispatch' script/server:49

This error occured while loading the following files:

action\_web\_service/dispatcher/action\_controller/redirect\_back\_error.rb

If I change the code to catch all exceptions then it works, but I would prefer not to do this.

Thanks

---

<div class="post-metadata">

**Author:** ![Mark\_James](https://avatars.discourse-cdn.com/v4/letter/m/58f4c7/32.png) [@Mark\_James](https://discuss.rubyonrails.org/u/Mark_James)\
**Post date:** [October 24, 2006, 12:44am UTC](https://discuss.rubyonrails.org/t/cannot-catch-actioncontroller-exception/3486/2 "2006-10-24T00:44:13Z")

</div>

joman wrote:

> I cannot catch the ActionController::RedirectBackError exception.
> 
> My code is:
> 
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;redirect\_to :back &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;rescue ActionController::RedirectBackError &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;redirect\_to :action =\> 'index' &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end
> 
> When the exception is raised I get the following error:
> 
> NameError in Release managementController#new
> 
> uninitialized constant RedirectBackError

Change the rescue to

rescue ::ActionController::RedirectBackError

---

<div class="post-metadata">

**Author:** ![joman](https://avatars.discourse-cdn.com/v4/letter/j/2bfe46/32.png) [@joman](https://discuss.rubyonrails.org/u/joman)\
**Post date:** [October 24, 2006, 1:27am UTC](https://discuss.rubyonrails.org/t/cannot-catch-actioncontroller-exception/3486/3 "2006-10-24T01:27:06Z")

</div>

That's it! Thanks very much.

Mark Reginald James wrote:
