Exception: GraphWeaver::TypeError

Inherits:
Error
  • Object
show all
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.



296
297
298
299
# File 'lib/graph_weaver/errors.rb', line 296

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.



294
295
296
# File 'lib/graph_weaver/errors.rb', line 294

def struct
  @struct
end

Instance Method Details

#to_hObject



301
302
303
# File 'lib/graph_weaver/errors.rb', line 301

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