# Constant for ActionController::RoutingError class?

**URL:** <https://www.ruby-forum.com/t/constant-for-actioncontroller-routingerror-class/131513>\
**Category:** Rails\
**Created:** [March 10, 2008, 9:45pm UTC](https://www.ruby-forum.com/t/constant-for-actioncontroller-routingerror-class/131513 "2008-03-10T21:45:28Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jrochkind](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/779978/32.png) [@jrochkind](https://www.ruby-forum.com/u/jrochkind)\
**Post date:** [March 10, 2008, 9:45pm UTC](https://www.ruby-forum.com/t/constant-for-actioncontroller-routingerror-class/131513/1 "2008-03-10T21:45:28Z")

</div>

I’m writing a default application-wide rescue\_action\_in\_public.

I’d like to do something special when the exception raised was a routing  
error. Inspecting in debugger, I get:

(rdb:1) p exception.class  
ActionController::RoutingError

Yet:

(rdb:1) p exception.kind\_of?( ActionController::RoutingError )  
NameError Exception: uninitialized constant  
ActionWebService::Dispatcher::ActionController::RoutingError

Huh? It’s an ActionController::RoutingError, yet I have no such thing  
as an ActionController::RoutingError loaded in my runtime?

How the heck do I test an exception to see if it’s the kind of exception  
that reports itself as ActionController::RoutingError?

Thanks for any advice.

---

<div class="post-metadata">

**Author:** ![jrochkind](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/779978/32.png) [@jrochkind](https://www.ruby-forum.com/u/jrochkind)\
**Post date:** [March 10, 2008, 10:15pm UTC](https://www.ruby-forum.com/t/constant-for-actioncontroller-routingerror-class/131513/2 "2008-03-10T22:15:09Z")

</div>

Found an answer although I still don’t really understand it.

```
http://dev.rubyonrails.org/ticket/6863

```

Jonathan R. wrote:

> I’m writing a default application-wide rescue\_action\_in\_public.
> 
> I’d like to do something special when the exception raised was a routing  
> error. Inspecting in debugger, I get:
> 
> (rdb:1) p exception.class  
> ActionController::RoutingError
> 
> Yet:
> 
> (rdb:1) p exception.kind\_of?( ActionController::RoutingError )  
> NameError Exception: uninitialized constant  
> ActionWebService::Dispatcher::ActionController::RoutingError
> 
> Huh? It’s an ActionController::RoutingError, yet I have no such thing  
> as an ActionController::RoutingError loaded in my runtime?
> 
> How the heck do I test an exception to see if it’s the kind of exception  
> that reports itself as ActionController::RoutingError?
> 
> Thanks for any advice.

---

<div class="post-metadata">

**Author:** ![jrochkind](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/779978/32.png) [@jrochkind](https://www.ruby-forum.com/u/jrochkind)\
**Post date:** [March 11, 2008, 10:36am UTC](https://www.ruby-forum.com/t/constant-for-actioncontroller-routingerror-class/131513/3 "2008-03-11T10:36:48Z")

</div>

On 10 Mar 2008, at 21:15, Jonathan R. wrote:

> Found an answer although I still don’t really understand it.
> 
> [http://dev.rubyonrails.org/ticket/6863](http://dev.rubyonrails.org/ticket/6863)

What it’s saying is that for some reason when it tries to lookup  
ActionController::RoutingError it looks in the wrong space (in  
ActionWebService).  
You can force it to look at the top level with by prepending :: (ie  
write ::ActionController::RoutingError instead of  
ActionController::RoutingError)

Fred
