Class: Zikrash::ExceptionInfo

Inherits:
Object
  • Object
show all
Defined in:
lib/zikrash/exception_info.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(exception) ⇒ ExceptionInfo

Returns a new instance of ExceptionInfo.



8
9
10
11
12
13
14
15
16
17
# File 'lib/zikrash/exception_info.rb', line 8

def initialize(exception)
  return false unless (exception.respond_to?(:message) && exception.respond_to?(:backtrace))

  self.exception_class = exception.is_a?(Class) ? exception.to_s : exception.class.to_s
  self.message = exception.message
  self.full_backtrace = exception.backtrace
  self.application_backtrace = Rails.backtrace_cleaner.clean(exception.backtrace)

  self
end

Instance Attribute Details

#application_backtraceObject

Returns the value of attribute application_backtrace.



6
7
8
# File 'lib/zikrash/exception_info.rb', line 6

def application_backtrace
  @application_backtrace
end

#exception_classObject

Returns the value of attribute exception_class.



3
4
5
# File 'lib/zikrash/exception_info.rb', line 3

def exception_class
  @exception_class
end

#full_backtraceObject

Returns the value of attribute full_backtrace.



5
6
7
# File 'lib/zikrash/exception_info.rb', line 5

def full_backtrace
  @full_backtrace
end

#messageObject

Returns the value of attribute message.



4
5
6
# File 'lib/zikrash/exception_info.rb', line 4

def message
  @message
end

Instance Method Details

#dataObject



19
20
21
22
23
24
25
26
27
28
# File 'lib/zikrash/exception_info.rb', line 19

def data
  all_backtrace, relevant_code = backtrace_with_relevant_code
  {
      class: exception_class,
      message: message,
      location: application_backtrace.first,
      full_backtrace: all_backtrace,
      relevant_code: relevant_code
  }
end