Skip to content

Instantly share code, notes, and snippets.

@elia
Created August 2, 2012 08:24
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 elia/c0eb3b5015d919e909a2 to your computer and use it in GitHub Desktop.
Save elia/c0eb3b5015d919e909a2 to your computer and use it in GitHub Desktop.
Notify deprecations via ExceptionNotifier
ActiveSupport::Deprecation.behavior = DeprecationNotifier.new
require 'ostruct'
class DeprecationNotifier
class DeprecationError < StandardError
def initialize message, callstack
super message
set_backtrace callstack
end
end
def call message, callstack
# Keep the default behavior at work
ActiveSupport::Deprecation.default_behavior(message, callstack)
# Let's mimic the controller exception :\
exception = DeprecationError.new(message, callstack)
request = OpenStruct.new(:env => {}, :session_options => {})
ExceptionNotification::Notifier.deliver_exception_notification(exception, self, request, data)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment