Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7952639
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T02:55:15+00:00 2026-06-04T02:55:15+00:00

I have a simple rails application with a few controller and some rake tasks.

  • 0

I have a simple rails application with a few controller and some rake tasks. A couple of tasks are executed by cron configured with whenever gem.

One of my task is executed daily and sometime it raises an exception and by default I receive this warning by cron

rake aborted!
undefined method `parameterize' for nil:NilClass

Tasks: TOP => mailboxes:clean_processed
(See full trace by running task with --trace)

I want to debug what’s happening and for this reason I’ve just installed this exception notification gem with this line in my Gemfile

gem "exception_notification", "~> 2.4.1", :require => 'exception_notifier'

and configured it in my application.rb file with

# enable exception notification
config.middleware.use ExceptionNotifier,
                      :email_prefix => "[MyAppName] ",
                      :sender_address => %{"notifier" <report@example.com>},
                      :exception_recipients => %w{me@example.com}

Since this gem is a rack middleware it only works for web requests and not for rake tasks. I’d like to enable it also for rake tasks and I found this gist which do the job.

It works, however it’s not DRY, I need to repeat gem configuration in that method and I also need to change all my rake tasks to enclose their statements in a block as in

exception_notify { actual_task_code }

Is there any better way to solve this?

P.S. If I need to change the notification gem would not be a problem because I added only a few lines of code to my project.

P.P.S. I know that I can also change the rake line in the crontab to add a --trace option, but I don’t like that solution, cause exception notifier imho is a better solution which helps also in web code.

Update I just found out this related question: exception_notification for delayed_job but both the answers use a similar trick.

I’m going to try with an online service like Airbrake (formerly known as hoptoad) or Exceptional, but both of them are paid services…

Update 2: I tried the Airbrake App, very nice application, but it suffer for the same problem, I still need to hack the Rakefile to notify exceptions from rake tasks. However the hack is less dry because you just need this code:

# notify exceptions
def exception_notify
  yield
rescue Exception => exception
  HoptoadNotifier.notify exception
  raise exception
end

There is no need to repeat any configuration parameter. I think I can’t do better than this to get notified of exceptions in rake tasks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T02:55:17+00:00Added an answer on June 4, 2026 at 2:55 am

    Airbrake gem patches Rake to allow rescuing, so it already does what I’m asking…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have wrote a few simple Rails application, accessing the database via the ActiveRecord
I am new to rails and have developed a simple rails application on my
I have a simple rails 2.3.4 application I am trying to get running with
I have created a simple blog application with Ruby on Rails. The applications consists
I have a Rails 3.2.2 application which is a simple company intranet, however although
I have built a very simple blog application using Ruby on Rails. New to
I have made a simple Rails application that allows people to comment on posts.
I have a really simple Rails application that allows users to register their attendance
I am working on a simple intranet application made with Rails 3.1. I have
I have a fairly simple Rails application that allows users to manage their clients

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.