Class: ExceptionHunter::ErrorCreator

Inherits:
Object
  • Object
show all
Defined in:
lib/exception_hunter/error_creator.rb

Overview

Core class in charge of the actual persistence of errors and notifications.

API:

  • public

Constant Summary collapse

HTTP_TAG =

API:

  • public

'HTTP'.freeze
WORKER_TAG =

API:

  • public

'Worker'.freeze
MANUAL_TAG =

API:

  • public

'Manual'.freeze
NOTIFICATION_DELAY =

API:

  • public

1.minute

Class Method Summary collapse

Class Method Details

.call(async_logging: Config.async_logging, tag: nil, **error_attrs) ⇒ ExceptionHunter::Error, false

Creates an error with the given attributes and persists it to the database.

Parameters:

  • (defaults to: nil)

    to append to the error if any

Returns:

  • the error or false if it was not possible to create it

API:

  • public



15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/exception_hunter/error_creator.rb', line 15

def call(async_logging: Config.async_logging, tag: nil, **error_attrs)
  return unless should_create?

  if async_logging
    # Time is sent in unix format and then converted to Time to avoid ActiveJob::SerializationError
    ::ExceptionHunter::AsyncLoggingJob.perform_later(tag, error_attrs.merge(occurred_at: Time.now.to_i))
  else
    create_error(tag, error_attrs)
  end
rescue ActiveRecord::RecordInvalid
  false
end