Class: Errorgap::Notice

Inherits:
Object
  • Object
show all
Defined in:
lib/errorgap/notice.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(error:, configuration:, context:, environment:, session:, params:) ⇒ Notice

Returns a new instance of Notice.



18
19
20
21
22
23
24
25
# File 'lib/errorgap/notice.rb', line 18

def initialize(error:, configuration:, context:, environment:, session:, params:)
  @error = error
  @configuration = configuration
  @context = context || {}
  @environment = environment || {}
  @session = session || {}
  @params = params || {}
end

Class Method Details

.from_exception(error, configuration:, context: {}, environment: {}, session: {}, params: {}) ⇒ Object



7
8
9
10
11
12
13
14
15
16
# File 'lib/errorgap/notice.rb', line 7

def self.from_exception(error, configuration:, context: {}, environment: {}, session: {}, params: {})
  new(
    error: error,
    configuration: configuration,
    context: context,
    environment: environment,
    session: session,
    params: params
  )
end

Instance Method Details

#to_hObject



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/errorgap/notice.rb', line 27

def to_h
  {
    project_id: @configuration.project_id,
    received_at: Time.now.utc.iso8601,
    errors: [
      {
        type: @error.class.name,
        message: @error.message.to_s,
        backtrace: backtrace_frames
      }
    ],
    context: default_context.merge(stringify_hash(@context)),
    environment: stringify_hash(@environment),
    session: stringify_hash(@session),
    params: filter_hash(@params)
  }
end