Class: OopsieExceptions::Payload

Inherits:
Object
  • Object
show all
Defined in:
lib/oopsie_exceptions/payload.rb

Constant Summary collapse

MAX_CAUSE_DEPTH =
10

Class Method Summary collapse

Class Method Details

.build(exception, context: {}, handled: true) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/oopsie_exceptions/payload.rb', line 8

def build(exception, context: {}, handled: true)
  config = OopsieExceptions.configuration
  backtrace = clean_backtrace(exception, config)

  {
    notifier: "OopsieExceptions",
    version: VERSION,
    timestamp: Time.now.utc.iso8601(3),
    app: {
      name: config.app_name,
      environment: config.environment
    },
    error: {
      class_name: exception.class.name,
      message: exception.message.to_s[0, 10_000],
      backtrace: backtrace,
      first_line: parse_backtrace_line(backtrace&.first),
      causes: collect_causes(exception),
      handled: handled
    },
    context: Context.current.merge(context),
    server: server_info
  }
end