Class: ExceptionHunter::ErrorCreator

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

Class Method Summary collapse

Class Method Details

.call(**error_attrs) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'app/services/exception_hunter/error_creator.rb', line 4

def call(**error_attrs)
  ActiveRecord::Base.transaction do
    error_attrs = extract_user_data(error_attrs)
    error = Error.new(error_attrs)
    error_group = ErrorGroup.find_matching_group(error) || ErrorGroup.new
    update_error_group(error_group, error)
    error.error_group = error_group
    error.save!
    error
  end
rescue ActiveRecord::RecordInvalid
  false
end