Exception: GraphWeaver::InputError
- 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
-
#field ⇒ Object
readonly
Returns the value of attribute field.
-
#struct ⇒ Object
readonly
Returns the value of attribute struct.
Instance Method Summary collapse
-
#initialize(message, field: nil, struct: nil) ⇒ InputError
constructor
A new instance of InputError.
- #to_h ⇒ Object
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(, field: nil, struct: nil) @field = field @struct = struct super() end |
Instance Attribute Details
#field ⇒ Object (readonly)
Returns the value of attribute field.
409 410 411 |
# File 'lib/graph_weaver/errors.rb', line 409 def field @field end |
#struct ⇒ Object (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_h ⇒ Object
422 423 424 |
# File 'lib/graph_weaver/errors.rb', line 422 def to_h super.merge("field" => field, "struct" => struct&.to_s).compact end |