class Periskop::Client::ExceptionInstance

ExceptionInstance has all metadata of a reported exception

Attributes

cause[RW]
class[RW]
message[RW]
stacktrace[RW]

Public Class Methods

from_exception(exception) click to toggle source
# File lib/periskop/client/models.rb, line 21
def self.from_exception(exception)
  ExceptionInstance.new(
    exception.class.name,
    exception.message,
    get_backtrace(exception),
    get_cause(exception)
  )
end
get_backtrace(exception) click to toggle source
# File lib/periskop/client/models.rb, line 40
def self.get_backtrace(exception)
  if !exception.backtrace.nil?
    exception.backtrace
  else
    caller
  end
end
get_cause(exception) click to toggle source
# 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
new(cls, message, stacktrace, cause) click to toggle source
# File lib/periskop/client/models.rb, line 14
def initialize(cls, message, stacktrace, cause)
  @class = cls
  @message = message
  @stacktrace = stacktrace
  @cause = cause
end

Public Instance Methods

as_json(_options = {}) click to toggle source
# File lib/periskop/client/models.rb, line 48
def as_json(_options = {})
  {
    class: @class,
    message: @message,
    stacktrace: @stacktrace,
    cause: @cause
  }
end
to_json(*options) click to toggle source
# File lib/periskop/client/models.rb, line 57
def to_json(*options)
  as_json(*options).to_json(*options)
end