-
-
Notifications
You must be signed in to change notification settings - Fork 479
/
error_event.rb
38 lines (32 loc) · 1021 Bytes
/
error_event.rb
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: nil)
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