Sha256: 7006dccc513b4f2254ec447d324f1ffd95587b6eb58c1f3b1969a3502b7528ec

Contents?: true

Size: 1.61 KB

Versions: 16

Compression:

Stored size: 1.61 KB

Contents

# typed: ignore

# Copyright (c) 2015 Sqreen. All Rights Reserved.
# Please refer to our terms for more information: https://www.sqreen.com/terms.html

require 'sqreen/kit/configuration'
require 'sqreen/kit/signals/point'
require 'sqreen/kit/signals/dto_helper'

# reference: https://github.com/sqreen/SignalsSchemas/blob/master/schemas/payload/sqreen_exception/2020-01-01T00_00_00_000Z/schema.cue

module Sqreen
  module Kit
    module Signals
      module Specialized
      end
    end
  end
end

class Sqreen::Kit::Signals::Specialized::SqreenException < Sqreen::Kit::Signals::Point
  PAYLOAD_SCHEMA_VERSION = 'sqreen_exception/2020-01-01T00:00:00.000Z'.freeze

  # @return [Hash]
  attr_accessor :infos

  # @return [Exception]
  attr_accessor :ruby_exception

  add_mandatory_attrs :source, :time, :ruby_exception

  validate_str_attr :source, /\A(?:sqreen:rule:[a-f0-9]{40}:.+)|(?:sqreen:agent:.+)\z/

  def self.attributes_for_to_h_self
    [] # don't include ruby_exception in list of attributes for to_h
  end

  def initialize(values = {})
    self.payload_schema = PAYLOAD_SCHEMA_VERSION
    self.signal_name = 'sq.agent.exception'
    self.time = values[:time] || Time.now
    self.source = values[:source] || Sqreen::Kit::Configuration.default_source
    super
  end

  def payload
    return nil unless @ruby_exception
    compact_hash({
                   klass: @ruby_exception.class.to_s,
                   message: @ruby_exception.message,
                   infos: @infos,
                 })
  end

  def location
    return nil unless @ruby_exception
    Sqreen::Kit::Signals::Location.new(exception: @ruby_exception)
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
sqreen-1.25.1 lib/sqreen/kit/signals/specialized/sqreen_exception.rb
sqreen-1.25.0 lib/sqreen/kit/signals/specialized/sqreen_exception.rb
sqreen-1.24.3 lib/sqreen/kit/signals/specialized/sqreen_exception.rb
sqreen-1.24.2 lib/sqreen/kit/signals/specialized/sqreen_exception.rb
sqreen-1.24.1 lib/sqreen/kit/signals/specialized/sqreen_exception.rb
sqreen-1.24.0 lib/sqreen/kit/signals/specialized/sqreen_exception.rb
sqreen-1.23.2 lib/sqreen/kit/signals/specialized/sqreen_exception.rb
sqreen-1.23.1 lib/sqreen/kit/signals/specialized/sqreen_exception.rb
sqreen-1.23.0 lib/sqreen/kit/signals/specialized/sqreen_exception.rb
sqreen-1.22.1 lib/sqreen/kit/signals/specialized/sqreen_exception.rb
sqreen-1.22.0-java lib/sqreen/kit/signals/specialized/sqreen_exception.rb
sqreen-1.22.0 lib/sqreen/kit/signals/specialized/sqreen_exception.rb
sqreen-1.21.1-java lib/sqreen/kit/signals/specialized/sqreen_exception.rb
sqreen-1.21.1 lib/sqreen/kit/signals/specialized/sqreen_exception.rb
sqreen-1.21.0-java lib/sqreen/kit/signals/specialized/sqreen_exception.rb
sqreen-1.21.0 lib/sqreen/kit/signals/specialized/sqreen_exception.rb