# Not catching my exception

**URL:** <https://www.ruby-forum.com/t/not-catching-my-exception/126224>\
**Category:** Ruby\
**Created:** [January 16, 2008, 2:56pm UTC](https://www.ruby-forum.com/t/not-catching-my-exception/126224 "2008-01-16T14:56:32Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Junkone](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e274bd/32.png) [@Junkone](https://www.ruby-forum.com/u/Junkone)\
**Post date:** [January 16, 2008, 2:56pm UTC](https://www.ruby-forum.com/t/not-catching-my-exception/126224/1 "2008-01-16T14:56:32Z")

</div>

Hello  
begin  
if(nil|pattern.match(details)) then  
id=$1  
rec=Scans.find(id)  
rec.scannable=MARKTRUE  
rec.save  
else  
badpattern=true  
end  
rescue RecordNotFound  
badpattern=true

end

I still get the prog stopping and printing out the exception  
Pl choose alert action? 3 1000  
e:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.4/lib/active\_support/  
dependencies.rb:266:in `load_missing_constant': uniniti alized constant RecordNotFound (NameError) from e:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.4/lib/ active_support/dependencies.rb:452:in`const\_missing’  
from e:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.4/lib/  
active\_support/dependencies.rb:464:in `const_missing' from MainMenu.rb:118:in`alertsMenu’

---

<div class="post-metadata">

**Author:** ![Junkone](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e274bd/32.png) [@Junkone](https://www.ruby-forum.com/u/Junkone)\
**Post date:** [January 16, 2008, 4:01pm UTC](https://www.ruby-forum.com/t/not-catching-my-exception/126224/2 "2008-01-16T16:01:26Z")

</div>

On Jan 16, 7:50 am, Junkone [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> ```
> rescue RecordNotFound
> badpattern=true
> 
> ```
> 
> end
> 
> I still get the prog stopping and printing out the exception  
> Pl choose alert action? 3 1000

uninitialized constant RecordNotFound (NameError)

This is telling you that RecordNotFound has not been defined. Maybe  
you’ve forgotten to include something?

---

<div class="post-metadata">

**Author:** ![Junkone](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e274bd/32.png) [@Junkone](https://www.ruby-forum.com/u/Junkone)\
**Post date:** [January 16, 2008, 4:55pm UTC](https://www.ruby-forum.com/t/not-catching-my-exception/126224/3 "2008-01-16T16:55:09Z")

</div>

2008/1/16, yermej [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> > I still get the prog stopping and printing out the exception  
> > Pl choose alert action? 3 1000
> 
> uninitialized constant RecordNotFound (NameError)
> 
> This is telling you that RecordNotFound has not been defined.  
> Maybe you’ve forgotten to include something?

I guess Junkone is refering to ActiveRecord::RecordNotFound  
exception, but he doesn’t give much info.

Furthermore, if it’s a ActiveRecord related problem, it should be  
asked in Rails-Talk mailing list.

– Jean-François.

---

<div class="post-metadata">

**Author:** ![Junkone](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e274bd/32.png) [@Junkone](https://www.ruby-forum.com/u/Junkone)\
**Post date:** [January 16, 2008, 7:06pm UTC](https://www.ruby-forum.com/t/not-catching-my-exception/126224/4 "2008-01-16T19:06:59Z")

</div>

On Jan 16, 10:54 am, Jean-François Trân [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I guess Junkone is refering to ActiveRecord::RecordNotFound  
> exception, but he doesn’t give much info.
> 
> Furthermore, if it’s a ActiveRecord related problem, it should be  
> asked in Rails-Talk mailing list.
> 
> – Jean-François.yes nol

now i realise i should have used ActiveRecord::RecordNotFound  
thanks
