Skip to content

Instantly share code, notes, and snippets.

@mikewadhera
Created May 17, 2012 22:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mikewadhera/2721967 to your computer and use it in GitHub Desktop.
Save mikewadhera/2721967 to your computer and use it in GitHub Desktop.
class ExceptionWithParams < Exception
attr_accessor :params
def initialize(params)
@params = params
end
end
class TestExceptionTask < Queueable::Tasks
def task_that_raises(arg)
raise "Bad things."
end
def on_processing_exception(exception, request_params)
raise ExceptionWithParams(request_params)
end
end
describe "exception handling" do
it "should pass request params when an exception is raised" do
lambda {
TestBackgroundTasks.send(:process, { :class => "TestExceptionTask", :action => "task_that_raises", :args => [123] })
}.should_raise(ExceptionWithParams)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment