mirror of
https://0xacab.org/sutty/sutty
synced 2024-11-23 02:06:22 +00:00
23 lines
487 B
Ruby
23 lines
487 B
Ruby
|
# 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
|