Exception: RLP::Error::ObjectSerializationError

Inherits:
SerializationError show all
Defined in:
lib/rlp/error.rb

Overview

Exception raised if serialization of a Sedes::Serializable object fails.

Instance Attribute Summary collapse

Attributes inherited from SerializationError

#obj

Instance Method Summary collapse

Constructor Details

#initialize(message: nil, obj: nil, sedes: nil, list_exception: nil) ⇒ ObjectSerializationError


90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# File 'lib/rlp/error.rb', line 90

def initialize(message: nil, obj: nil, sedes: nil, list_exception: nil)
  if message.nil?
    raise ArgumentError, "list_exception and sedes must be present" if list_exception.nil? || sedes.nil?

    if list_exception.element_exception
      field = sedes.serializable_fields.keys[list_exception.index]
      message = "Serialization failed because of field #{field} ('#{list_exception.element_exception}')"
    else
      field = nil
      message = "Serialization failed because of underlying list ('#{list_exception}')"
    end
  else
    field = nil
  end

  super(message, obj)

  @field = field
  @list_exception = list_exception
end

Instance Attribute Details

#fieldObject (readonly)

Returns the value of attribute field


83
84
85
# File 'lib/rlp/error.rb', line 83

def field
  @field
end