Class: LaunchDarkly::Impl::DataSystem::ProtocolV2::Error Private

Inherits:
Object
  • Object
show all
Defined in:
lib/ldclient-rb/impl/data_system/protocolv2.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Error represents an error event.

Since:

  • 5.5.0

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(payload_id:, reason:) ⇒ Error

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Error.

Parameters:

  • payload_id (String)

    The payload ID

  • reason (String)

    The reason for the error

Since:

  • 5.5.0



202
203
204
205
# File 'lib/ldclient-rb/impl/data_system/protocolv2.rb', line 202

def initialize(payload_id:, reason:)
  @payload_id = payload_id
  @reason = reason
end

Instance Attribute Details

#payload_idString (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns The payload ID.

Returns:

  • (String)

    The payload ID

Since:

  • 5.5.0



193
194
195
# File 'lib/ldclient-rb/impl/data_system/protocolv2.rb', line 193

def payload_id
  @payload_id
end

#reasonString (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns The reason for the error.

Returns:

  • (String)

    The reason for the error

Since:

  • 5.5.0



196
197
198
# File 'lib/ldclient-rb/impl/data_system/protocolv2.rb', line 196

def reason
  @reason
end

Class Method Details

.from_h(data) ⇒ Error

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Deserializes an Error from a JSON-compatible hash.

Parameters:

  • data (Hash)

    The hash representation

Returns:

Raises:

  • (ArgumentError)

    if required fields are missing

Since:

  • 5.5.0



226
227
228
229
230
231
232
233
# File 'lib/ldclient-rb/impl/data_system/protocolv2.rb', line 226

def self.from_h(data)
  payload_id = data[:payloadId]
  reason = data[:reason]

  raise ArgumentError, "Missing required fields in Error" if payload_id.nil? || reason.nil?

  new(payload_id: payload_id, reason: reason)
end

Instance Method Details

#to_hHash

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Serializes the Error to a JSON-compatible hash.

Returns:

  • (Hash)

Since:

  • 5.5.0



212
213
214
215
216
217
# File 'lib/ldclient-rb/impl/data_system/protocolv2.rb', line 212

def to_h
  {
    payloadId: @payload_id,
    reason: @reason,
  }
end