[Backgroundrb-devel] Exception Handling

Tobias Overkamp tov-backgroundrb at overkamp.org
Tue Jun 23 06:27:25 EDT 2009


Hi folks!
I'm still starting with BackgroundRB and I wonder if it is possible to  
to put some kind of exception handling (begin/rescue etc.) around each  
method in my worker.

In the example below I want to make sure that the whole method could  
be processed correctly before I commit the data in the database.
Of course I don't want to write the begin-rescue idiom in every method  
(DRY). Is there some kind of hook/callback that I'm missing?

Sample:

class TransferWorker < BackgrounDRb::MetaWorker
  set_worker_name :transfer_worker


  def request_transfer_from_registry

   begin
    ActiveRecord::Base.transaction do
      transfer = Order::OrderTransfer.new(:xml => args[:xml])
      transfer.fetch_from_xml_by_id
    end
   rescue Exception => e
    #notify whomever...
   end

  end

end


Regards,

Tobias


More information about the Backgroundrb-devel mailing list