Method: Sentry::Client#event_from_exception

Defined in:
lib/sentry/client.rb

#event_from_exception(exception, hint = {}) ⇒ Event?

Initializes an Event object with the given exception. Returns nil if the exception’s class is excluded from reporting.

Parameters:

  • exception (Exception)

    the exception to be reported.

  • hint (Hash) (defaults to: {})

    the hint data that’ll be passed to before_send callback and the scope’s event processors.

Returns:



144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
# File 'lib/sentry/client.rb', line 144

def event_from_exception(exception, hint = {})
  return unless @configuration.sending_allowed?

  ignore_exclusions = hint.delete(:ignore_exclusions) { false }
  return if !ignore_exclusions && !@configuration.exception_class_allowed?(exception)

  integration_meta = Sentry.integrations[hint[:integration]]
  mechanism = hint.delete(:mechanism) { Mechanism.new }

  ErrorEvent.new(configuration: configuration, integration_meta: integration_meta).tap do |event|
    event.add_exception_interface(exception, mechanism: mechanism)
    event.add_threads_interface(crashed: true)
    event.level = :error
  end
end