Exception: RLP::Error::ObjectDeserializationError

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

Overview

Exception raised if deserialization by a Sedes::Serializable fails.

Instance Attribute Summary collapse

Attributes inherited from DeserializationError

#serial

Instance Method Summary collapse

Constructor Details

#initialize(message: nil, serial: nil, sedes: nil, list_exception: nil) ⇒ ObjectDeserializationError

Returns a new instance of ObjectDeserializationError.

Parameters:


124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
# File 'lib/rlp/error.rb', line 124

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

    if list_exception.element_exception
      raise ArgumentError, "sedes must be present" if sedes.nil?

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

  super(message, serial)

  @sedes = sedes
  @field = field
  @list_exception = list_exception
end

Instance Attribute Details

#fieldObject (readonly)

Returns the value of attribute field


116
117
118
# File 'lib/rlp/error.rb', line 116

def field
  @field
end

#list_exceptionObject (readonly)

Returns the value of attribute list_exception


116
117
118
# File 'lib/rlp/error.rb', line 116

def list_exception
  @list_exception
end

#sedesObject (readonly)

Returns the value of attribute sedes


116
117
118
# File 'lib/rlp/error.rb', line 116

def sedes
  @sedes
end