5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-05-18 20:20:48 +00:00

feat: poder serializar las excepciones

This commit is contained in:
f 2023-03-30 13:07:25 -03:00
parent 71afdc16ae
commit d3166f2c5a
2 changed files with 30 additions and 0 deletions

View file

@ -0,0 +1,8 @@
# frozen_string_literal: true
ActiveJob::Serializers.add_serializers ActiveJob::Serializers::ExceptionSerializer
# Notificar los errores
Que.error_notifier = proc do |error, job|
ExceptionNotifier.notify_exception(error, data: job)
end

View file

@ -0,0 +1,22 @@
# frozen_string_literal: true
require 'json/add/exception'
module ActiveJob
module Serializers
class ExceptionSerializer < ObjectSerializer # :nodoc:
def serialize(ex)
super('value' => { 'class' => ex.class.name, 'exception' => ex.as_json })
end
def deserialize(hash)
hash.dig('value', 'class').constantize.json_create(hash.dig('value', 'exception'))
end
private
def klass
Exception
end
end
end
end