Class: ExceptionSerializer
- Inherits:
-
ActiveJob::Serializers::ObjectSerializer
- Object
- ActiveJob::Serializers::ObjectSerializer
- ExceptionSerializer
- Defined in:
- lib/acidic_job/serializer.rb
Instance Method Summary collapse
Instance Method Details
#deserialize(hash) ⇒ Object
71 72 73 74 75 76 77 78 |
# File 'lib/acidic_job/serializer.rb', line 71 def deserialize(hash) exception_class = hash["class"].constantize exception = exception_class.new(hash["message"]) exception.set_backtrace(hash["backtrace"].map do |path, location| [path, location].join("/") end) exception end |
#serialize(exception) ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/acidic_job/serializer.rb', line 52 def serialize(exception) hash = { "class" => exception.class.name, "message" => exception., "cause" => exception.cause, "backtrace" => {} } exception.backtrace.map do |trace| path, _, location = trace.rpartition("/") next if hash["backtrace"].key?(path) hash["backtrace"][path] = location end super(hash) end |
#serialize?(argument) ⇒ Boolean
80 81 82 |
# File 'lib/acidic_job/serializer.rb', line 80 def serialize?(argument) defined?(Exception) && argument.is_a?(Exception) end |