# Exception handling

**URL:** <https://www.ruby-forum.com/t/exception-handling/145540>\
**Category:** Rails\
**Created:** [August 11, 2008, 12:12pm UTC](https://www.ruby-forum.com/t/exception-handling/145540 "2008-08-11T12:12:48Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![sijo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/da6949/32.png) [@sijo](https://www.ruby-forum.com/u/sijo)\
**Post date:** [August 11, 2008, 12:12pm UTC](https://www.ruby-forum.com/t/exception-handling/145540/1 "2008-08-11T12:12:48Z")

</div>

Hi  
I have code in model as

def self.record\_paginate\_pb(search\_pb\_ui\_hash,page)  
problem\_number=search\_pb\_ui\_hash[:number]  
problem\_priority\_id=search\_pb\_ui\_hash[:problem\_priority\_id]  
search\_problem = self.find\_where\_options :order =\> ‘created\_on DESC’ do  
|pb|  
pb.number1.downcase =~ “%”+problem\_number.downcase+"%" if  
!problem\_number.nil?  
pb.problem\_priority\_id== problem\_priority\_id  
end  
rescue ActiveRecord::ActiveRecordError =\> e:  
puts 'error happened '+e.to\_s  
else  
paginate search\_problem.update( :per\_page=\>10,:page =\> page )  
end  
and this is called from controller as  
@search\_pb\_result=Problem.record\_paginate\_pb(params[:problem],  
params[:page])

I am new to ruby’s exception handling (learning)…How can I write a  
rescue block for the above code …I tried like above but is not  
working…Could you please help me and also point to some good tutorials  
on rails exception handling?

Thanks in advance  
Sijo
