Exception: GraphWeaver::InputError

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

Overview

Raised when the variables passed to a query or mutation can't be built into the generated input structs — an unknown or typo'd input key, a missing required input field, an out-of-range enum, or a wrong-typed field. This is the "the caller's input was invalid" error: rescue it at an API boundary to return a 422. #field names the offending input field when known, #struct the input type being built; the underlying TypeError/KeyError/ArgumentError is preserved as #cause.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message, field: nil, struct: nil) ⇒ InputError

Returns a new instance of InputError.



415
416
417
418
419
# File 'lib/graph_weaver/errors.rb', line 415

def initialize(message, field: nil, struct: nil)
  @field = field
  @struct = struct
  super(message)
end

Instance Attribute Details

#fieldObject (readonly)

Returns the value of attribute field.



409
410
411
# File 'lib/graph_weaver/errors.rb', line 409

def field
  @field
end

#structObject (readonly)

Returns the value of attribute struct.



412
413
414
# File 'lib/graph_weaver/errors.rb', line 412

def struct
  @struct
end

Instance Method Details

#to_hObject



422
423
424
# File 'lib/graph_weaver/errors.rb', line 422

def to_h
  super.merge("field" => field, "struct" => struct&.to_s).compact
end