Class: Kobako::Wire::Exception
- Inherits:
-
Data
- Object
- Data
- Kobako::Wire::Exception
- Defined in:
- lib/kobako/wire/exception.rb
Overview
Wire-level value object for an ext-0x02 Exception envelope.
SPEC pins the payload (Wire Codec → Ext Types → ext 0x02) to a msgpack map with exactly three keys:
* "type" — one of "runtime", "argument", "disconnected", "undefined"
* "message" — human-readable string
* "details" — any wire-legal value, or nil when absent
This object holds the encoded form. Reifying the corresponding Ruby exception class (RuntimeError, ArgumentError, Kobako::ServiceError, …) is the responsibility of the dispatch layer, not the codec.
Built on Data.define so equality, hash, and immutability are inherited from the value-object machinery; only the field invariants ride on top.
Constant Summary collapse
- VALID_TYPES =
%w[runtime argument disconnected undefined].freeze
Instance Attribute Summary collapse
-
#details ⇒ Object
readonly
Returns the value of attribute details.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
-
#initialize(type:, message:, details: nil) ⇒ Exception
constructor
VALID_TYPESis attached to the Exception class below this block.
Constructor Details
#initialize(type:, message:, details: nil) ⇒ Exception
VALID_TYPES is attached to the Exception class below this block. Reach it through self.class::VALID_TYPES — Data.define’s block scope resolves bare constants against the enclosing Wire module, so a bare VALID_TYPES would raise NameError. Same pattern as Wire::Handle.
26 27 28 29 30 31 32 33 |
# File 'lib/kobako/wire/exception.rb', line 26 def initialize(type:, message:, details: nil) valid_types = self.class::VALID_TYPES raise ArgumentError, "type must be String" unless type.is_a?(String) raise ArgumentError, "message must be String" unless .is_a?(String) raise ArgumentError, "type=#{type.inspect} not one of #{valid_types.inspect}" unless valid_types.include?(type) super end |
Instance Attribute Details
#details ⇒ Object (readonly)
Returns the value of attribute details
20 21 22 |
# File 'lib/kobako/wire/exception.rb', line 20 def details @details end |
#message ⇒ Object (readonly)
Returns the value of attribute message
20 21 22 |
# File 'lib/kobako/wire/exception.rb', line 20 def @message end |
#type ⇒ Object (readonly)
Returns the value of attribute type
20 21 22 |
# File 'lib/kobako/wire/exception.rb', line 20 def type @type end |