Sha256: dd337e1f7a8a53a9b013c472211507dce11dc2d6f875aa1480162f57aa5a62b4

Contents?: true

Size: 468 Bytes

Versions: 5

Compression:

Stored size: 468 Bytes

Contents

module BerkeleyLibrary
  module Logging
    module ExceptionSerializer
      def serialize_exc(ex, serialized = Set.new)
        raw_result = { name: ex.class.name, message: ex.message, stack: ex.backtrace }
        raw_result.tap do |result|
          next unless (cause = ex.cause)
          next if (serialized << ex).include?(cause) # prevent circular references

          result[:cause] = serialize_exc(cause, serialized)
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
berkeley_library-logging-0.2.7 lib/berkeley_library/logging/exception_serializer.rb
berkeley_library-logging-0.2.6.2 lib/berkeley_library/logging/exception_serializer.rb
berkeley_library-logging-0.2.6.1 lib/berkeley_library/logging/exception_serializer.rb
berkeley_library-logging-0.2.6 lib/berkeley_library/logging/exception_serializer.rb
berkeley_library-logging-0.2.5 lib/berkeley_library/logging/exception_serializer.rb