Exception: GraphWeaver::TypeError

Inherits:
Error
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/graph_weaver/errors.rb

Overview

Raised when a response can't be cast into the generated structs — the wire data disagreed with the types the schema promised at generation time (a nil where non-null was declared, a malformed scalar, an unknown enum value). #struct names the generated type that failed; #cause carries the original TypeError/KeyError with the offending prop in its message.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(struct:, error: nil, message: nil) ⇒ TypeError

Returns a new instance of TypeError.



387
388
389
390
# File 'lib/graph_weaver/errors.rb', line 387

def initialize(struct:, error: nil, message: nil)
  @struct = struct
  super("failed to cast response into #{struct}: #{message || error&.message}")
end

Instance Attribute Details

#structObject (readonly)

Returns the value of attribute struct.



384
385
386
# File 'lib/graph_weaver/errors.rb', line 384

def struct
  @struct
end

Instance Method Details

#to_hObject



393
394
395
# File 'lib/graph_weaver/errors.rb', line 393

def to_h
  super.merge("struct" => struct.to_s, "cause" => cause&.message)
end