Exception: Axn::Async::UnserializableArgument

Inherits:
ArgumentError
  • Object
show all
Includes:
Error
Defined in:
lib/axn/exceptions.rb

Overview

Raised at enqueue when an async argument cannot be serialized for background execution. Field-aware: names the offending field, its class, and how to fix it. The fix hint is delegated to the serialization layer (Axn::Internal::AsyncSerialization), resolved at message time so this stays a pure exception definition.

Instance Method Summary collapse

Constructor Details

#initialize(field:, value:) ⇒ UnserializableArgument

Returns a new instance of UnserializableArgument.



436
437
438
439
440
# File 'lib/axn/exceptions.rb', line 436

def initialize(field:, value:)
  @field = field
  @value = value
  super()
end

Instance Method Details

#messageObject

Same shape as UnserializableValue#message above, and through the same owners: @value is caller-supplied, so its class is named via Internal::RenderedClassName rather than @value.class, and @field is a DECLARED name — foreign bytes of its own — so it is rendered rather than joined to the rendered class name beside it.

The hint is normalized here too, at the join. It is another module's method choosing between three texts, and which text that is must not be able to decide whether this message composes — the ordinary reason #message renders every operand of a composition rather than the ones known today to need it.



450
451
452
453
# File 'lib/axn/exceptions.rb', line 450

def message
  "Cannot serialize argument `#{Axn::Internal::RenderedText.of(@field)}` (#{value_class_name}) for " \
    "async execution. #{Axn::Internal::RenderedText.of(Axn::Internal::AsyncSerialization._unserializable_hint(@value))}"
end