Skip to content

Instantly share code, notes, and snippets.

@eliotsykes
Last active July 27, 2017 16:09
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 eliotsykes/56d08053da650c93d48ef5be90493e60 to your computer and use it in GitHub Desktop.
Save eliotsykes/56d08053da650c93d48ef5be90493e60 to your computer and use it in GitHub Desktop.
Check Rollbar is reporting errors raised in rake tasks
# Create file at lib/tasks/check_rollbar.rake
require 'securerandom'
# Run this with `heroku run rake check_rollbar`
desc "Check Rollbar reports errors raised in Rake tasks"
task check_rollbar: :environment do
unique_msg = "Hello from rake check_rollbar (unique identifier: #{SecureRandom.hex})"
begin
raise ActiveRecord::RecordNotFound, unique_msg
ensure
puts "Check your Rollbar dashboard for an ActiveRecord::RecordNotFound error in production with the unique message '#{unique_msg}'"
puts "If Rollbar has not reported the exact error, then Rollbar will not report errors originating from rake tasks. This is an issue as you'll not know when your rake tasks are failing."
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment