File: error_event.rb

package info (click to toggle)
ruby-sentry-ruby 5.18.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 564 kB
  • sloc: ruby: 4,701; makefile: 8; sh: 4
file content (38 lines) | stat: -rw-r--r-- 1,017 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# frozen_string_literal: true

module Sentry
  # ErrorEvent represents error or normal message events.
  class ErrorEvent < Event
    # @return [ExceptionInterface]
    attr_reader :exception

    # @return [ThreadsInterface]
    attr_reader :threads

    # @return [Hash]
    def to_hash
      data = super
      data[:threads] = threads.to_hash if threads
      data[:exception] = exception.to_hash if exception
      data
    end

    # @!visibility private
    def add_threads_interface(backtrace: nil, **options)
      @threads = ThreadsInterface.build(
        backtrace: backtrace,
        stacktrace_builder: @stacktrace_builder,
        **options
      )
    end

    # @!visibility private
    def add_exception_interface(exception, mechanism:)
      if exception.respond_to?(:sentry_context)
        @extra.merge!(exception.sentry_context)
      end

      @exception = Sentry::ExceptionInterface.build(exception: exception, stacktrace_builder: @stacktrace_builder, mechanism: mechanism)
    end
  end
end