Class: WhoopsRailsNotifier::ExceptionStrategy
- Inherits:
-
WhoopsNotifier::Strategy
- Object
- WhoopsNotifier::Strategy
- WhoopsRailsNotifier::ExceptionStrategy
- Defined in:
- lib/whoops_rails_notifier/exception_strategy.rb
Instance Attribute Summary collapse
-
#environment ⇒ Object
Returns the value of attribute environment.
-
#service ⇒ Object
Returns the value of attribute service.
Instance Method Summary collapse
- #add_report_builders ⇒ Object
-
#initialize(strategy_name) ⇒ ExceptionStrategy
constructor
A new instance of ExceptionStrategy.
Constructor Details
#initialize(strategy_name) ⇒ ExceptionStrategy
Returns a new instance of ExceptionStrategy.
4 5 6 7 8 9 10 11 |
# File 'lib/whoops_rails_notifier/exception_strategy.rb', line 4 def initialize(strategy_name) super self.service = ::Rails.application.class.name.split("::").first.downcase self.environment = ::Rails.env add_report_builders end |
Instance Attribute Details
#environment ⇒ Object
Returns the value of attribute environment.
3 4 5 |
# File 'lib/whoops_rails_notifier/exception_strategy.rb', line 3 def environment @environment end |
#service ⇒ Object
Returns the value of attribute service.
3 4 5 |
# File 'lib/whoops_rails_notifier/exception_strategy.rb', line 3 def service @service end |
Instance Method Details
#add_report_builders ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/whoops_rails_notifier/exception_strategy.rb', line 13 def add_report_builders self.add_report_builder(:basic_details) do |report, evidence| report.service = self.service report.environment = self.environment report.event_type = "exception" report. = evidence[:exception]. report.event_time = Time.now end self.add_report_builder(:details) do |report, evidence| exception = evidence[:exception] rack_env = evidence[:rack_env] details = {} details[:backtrace] = exception.backtrace.collect{ |line| line.sub(/^#{ENV['GEM_HOME']}/, '$GEM_HOME').sub(/^#{Rails.root}/, '$Rails.root') } details[:params] = rack_env["action_dispatch.request.parameters"] report.details = details end self.add_report_builder(:create_event_group_identifier) do |report, evidence| identifier = "#{evidence[:controller]}##{evidence[:action]}" identifier << evidence[:exception].backtrace.collect{|l| l.sub(Rails.root, "")}.join("\n") report.event_group_identifier = Digest::MD5.hexdigest(identifier) end end |