Exception: Takagi::Errors::ProtocolError

Inherits:
TakagiError
  • Object
show all
Defined in:
lib/takagi/errors.rb

Overview

Raised when protocol/transport operations fail

Instance Attribute Summary

Attributes inherited from TakagiError

#context, #suggestions

Class Method Summary collapse

Methods inherited from TakagiError

#initialize

Constructor Details

This class inherits a constructor from Takagi::Errors::TakagiError

Class Method Details

.deserialization_failed(content_format, error, payload_preview) ⇒ Object



283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
# File 'lib/takagi/errors.rb', line 283

def self.deserialization_failed(content_format, error, payload_preview)
  new(
    "Failed to deserialize request with content-format #{content_format}",
    context: {
      content_format: content_format,
      error: error.message,
      payload_preview: payload_preview
    },
    suggestions: [
      "Verify the payload is valid #{content_format} format",
      "Check Content-Format option matches actual payload format",
      "Try sending with explicit Content-Format header"
    ]
  )
end

.serialization_failed(content_format, error) ⇒ Object



268
269
270
271
272
273
274
275
276
277
278
279
280
281
# File 'lib/takagi/errors.rb', line 268

def self.serialization_failed(content_format, error)
  new(
    "Failed to serialize response for content-format #{content_format}",
    context: {
      content_format: content_format,
      error: error.message
    },
    suggestions: [
      "Check that your response object is serializable",
      "Verify the content-format is registered: Serialization::Registry.registered?(#{content_format})",
      "Try using a different content-format in your request"
    ]
  )
end

.unsupported_protocol(protocol, supported) ⇒ Object



254
255
256
257
258
259
260
261
262
263
264
265
266
# File 'lib/takagi/errors.rb', line 254

def self.unsupported_protocol(protocol, supported)
  new(
    "Unsupported protocol: #{protocol.inspect}",
    context: {
      requested: protocol,
      supported: supported
    },
    suggestions: [
      "Use one of: #{supported.map(&:inspect).join(', ')}",
      "Example: run!(protocols: [:udp, :tcp])"
    ]
  )
end