# Rescue Error in Module

**URL:** <https://www.ruby-forum.com/t/rescue-error-in-module/115166>\
**Category:** Rails\
**Created:** [September 21, 2007, 10:05am UTC](https://www.ruby-forum.com/t/rescue-error-in-module/115166 "2007-09-21T10:05:28Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![phudson1442](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/c68b51/32.png) [@phudson1442](https://www.ruby-forum.com/u/phudson1442)\
**Post date:** [September 21, 2007, 10:05am UTC](https://www.ruby-forum.com/t/rescue-error-in-module/115166/1 "2007-09-21T10:05:28Z")

</div>

Hi,

I am not sure why, but I get the following error when I try to catch a  
specific exception:

uninitialized constant One::ActiveRecord::RecordNotFound

Here is some example code that I will use for simplification.

Why can’t I specify the RecordNotFound in the rescue?

I am calling the check\_object method from the ApplicationController on a  
before filter.

So Confused!!!

---------- CODE ----------

module One  
module Two

def check\_object

```
id = 12345

begin
  object = ObjectName.find(id)
rescue ActiveRecord::RecordNotFound => e
  logger.debug("#{e} : #{id}")
end

# more code would go here.

```

end

end  
end

ActionController::Base.send :include, One::Two
