Subject: Not able to collect parameters passed during a rake task

Original Post neerajdotname's Avatar

neerajdotname

08 Feb, 2010 05:26 PM via web

This is how I am handling exception in a rake task.

Fan.find(:all).each do |fan|
begin

raise 'boom'

rescue Exception => e

HoptoadNotifier.notify(e, {:fan_id => 100, :event_id => 200})

end end

When I get the exception notfication from hoptoad notifier then I do not see fan_id or event_id .

Here is what I got in the email.

Error Message:

RuntimeError: boom3

Where:

# [PROJECT_ROOT]/lib/tasks/notify_fans.rake, line 28

Request:

params: {}
rails_root: /Users/nsingh/dev/eii/eii
url: ~

Session:

? !ruby/symbol data : {}

Environment:

RAILS_ENV: production

Backtrace:

[PROJECT_ROOT]/lib/tasks/notify_fans.rake:28 [PROJECT_ROOT]/lib/tasks/notify_fans.rake:25:in each' [PROJECT_ROOT]/lib/tasks/notify_fans.rake:25 [GEM_ROOT]/gems/activerecord-2.3.5/lib/active_record/named_scope.rb:109:ineach' [GEM_ROOT]/gems/activerecord-2.3.5/lib/active_record/named_scope.rb:109:in __send__' [GEM_ROOT]/gems/activerecord-2.3.5/lib/active_record/named_scope.rb:109:ineach' [PROJECT_ROOT]/lib/tasks/notify_fans.rake:24 [PROJECT_ROOT]/lib/tasks/notify_fans.rake:11:in run' [PROJECT_ROOT]/lib/tasks/notify_fans.rake:22 [GEM_ROOT]/gems/rake-0.8.7/lib/rake.rb:636:incall' [GEM_ROOT]/gems/rake-0.8.7/lib/rake.rb:636:in execute' [GEM_ROOT]/gems/rake-0.8.7/lib/rake.rb:631:ineach' [GEM_ROOT]/gems/rake-0.8.7/lib/rake.rb:631:in execute' [GEM_ROOT]/gems/rake-0.8.7/lib/rake.rb:597:ininvoke_with_call_chain' /usr/local/lib/ruby/1.8/monitor.rb:242:in synchronize' [GEM_ROOT]/gems/rake-0.8.7/lib/rake.rb:590:ininvoke_with_call_chain' [GEM_ROOT]/gems/rake-0.8.7/lib/rake.rb:583:in invoke' [GEM_ROOT]/gems/rake-0.8.7/lib/rake.rb:2051:ininvoke_task' [GEM_ROOT]/gems/rake-0.8.7/lib/rake.rb:2029:in top_level' [GEM_ROOT]/gems/rake-0.8.7/lib/rake.rb:2029:ineach' [GEM_ROOT]/gems/rake-0.8.7/lib/rake.rb:2029:in top_level' [GEM_ROOT]/gems/rake-0.8.7/lib/rake.rb:2068:instandard_exception_handling' [GEM_ROOT]/gems/rake-0.8.7/lib/rake.rb:2023:in top_level' [GEM_ROOT]/gems/rake-0.8.7/lib/rake.rb:2001:inrun' [GEM_ROOT]/gems/rake-0.8.7/lib/rake.rb:2068:in standard_exception_handling' [GEM_ROOT]/gems/rake-0.8.7/lib/rake.rb:1998:inrun' [GEM_ROOT]/gems/rake-0.8.7/bin/rake:31 /usr/local/bin/rake:19:in `load' /usr/local/bin/rake:19

  1. Support Staff 2 Posted by thoughtbot on 08 Feb, 2010 06:46 PM

    thoughtbot's Avatar

    Hi,

    The notifier doesn't currently support arbitrary variables in notifications. However, you could send custom params in a rake task by making it look like a web request:

    HoptoadNotifier.notify(e,
                          :url        => 'rake',
                          :component  => 'rake',
                          :parameters => {:fan_id => 100, :event_id => 200})
    

    Does that make sense?

    Thanks,

    -Joe

Reply to this discussion

Internal reply

Formatting help or Preview

Attached Files

You can attach files up to 10MB

What is 14 minus 4?

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.