# exception handling

**URL:** <https://discuss.rubyonrails.org/t/exception-handling/33075>\
**Category:** rubyonrails-talk\
**Created:** [August 11, 2008, 10:12am UTC](https://discuss.rubyonrails.org/t/exception-handling/33075 "2008-08-11T10:12:48Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![11175](https://avatars.discourse-cdn.com/v4/letter/1/8edcca/32.png) [@11175](https://discuss.rubyonrails.org/u/11175)\
**Post date:** [August 11, 2008, 10:12am UTC](https://discuss.rubyonrails.org/t/exception-handling/33075/1 "2008-08-11T10:12:48Z")

</div>

Hi &nbsp;&nbsp;&nbsp;&nbsp;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\>

&nbsp;&nbsp;&nbsp;&nbsp;pb.number1.downcase =~ "%"+problem\_number.downcase+"%" if !problem\_number.nil? &nbsp;&nbsp;&nbsp;&nbsp;pb.problem\_priority\_id== problem\_priority\_id &nbsp;&nbsp;end &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;rescue ActiveRecord::ActiveRecordError =\> e: &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;puts 'error happened '+e.to\_s &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;paginate search\_problem.update( :per\_page=\>10,:page =\> page ) end &nbsp;&nbsp;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
