Class: Periskop::Client::ExceptionInstance

Inherits:
Object
  • Object
show all
Defined in:
lib/periskop/client/models.rb

Overview

ExceptionInstance has all metadata of a reported exception

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cls, message, stacktrace, cause) ⇒ ExceptionInstance

Returns a new instance of ExceptionInstance.



14
15
16
17
18
19
# File 'lib/periskop/client/models.rb', line 14

def initialize(cls, message, stacktrace, cause)
  @class = cls
  @message = message
  @stacktrace = stacktrace
  @cause = cause
end

Instance Attribute Details

#causeObject

Returns the value of attribute cause.



12
13
14
# File 'lib/periskop/client/models.rb', line 12

def cause
  @cause
end

#classObject

Returns the value of attribute class.



12
13
14
# File 'lib/periskop/client/models.rb', line 12

def class
  @class
end

#messageObject

Returns the value of attribute message.



12
13
14
# File 'lib/periskop/client/models.rb', line 12

def message
  @message
end

#stacktraceObject

Returns the value of attribute stacktrace.



12
13
14
# File 'lib/periskop/client/models.rb', line 12

def stacktrace
  @stacktrace
end

Class Method Details

.from_exception(exception) ⇒ Object



21
22
23
24
25
26
27
28
# File 'lib/periskop/client/models.rb', line 21

def self.from_exception(exception)
  ExceptionInstance.new(
    exception.class.name,
    exception.message,
    exception.backtrace,
    get_cause(exception)
  )
end

.get_cause(exception) ⇒ Object



30
31
32
33
34
35
36
37
38
# File 'lib/periskop/client/models.rb', line 30

def self.get_cause(exception)
  if RUBY_VERSION > '2.0'
    if exception.cause.is_a?(Exception)
      return ExceptionInstance.from_exception(exception.cause)
    end
  end

  nil
end

Instance Method Details

#as_json(_options = {}) ⇒ Object



40
41
42
43
44
45
46
47
# File 'lib/periskop/client/models.rb', line 40

def as_json(_options = {})
  {
    class: @class,
    message: @message,
    stacktrace: @stacktrace,
    cause: @cause
  }
end

#to_json(*options) ⇒ Object



49
50
51
# File 'lib/periskop/client/models.rb', line 49

def to_json(*options)
  as_json(*options).to_json(*options)
end