Exception: GraphWeaver::Error

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

Overview

Base for every error GraphWeaver raises — rescue this to catch them all. #message is the human-friendly side; #to_h is the machine side — a JSON-ready Hash (string keys) for logging, agents, or surfacing structured failures to users. One subclass per failure site — TransportError (never reached the server), ServerError (non-2xx), QueryError (GraphQL-level errors), TypeError (response wouldn't cast), InputError (bad variables), ValidationError (build time) — each merging its specifics into #to_h.

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Error

Returns a new instance of Error.



23
24
25
26
# File 'lib/graph_weaver/errors.rb', line 23

def initialize(*args)
  super
  GraphWeaver.log(:warn) { "#{self.class.name}: #{message}" }
end

Instance Method Details

#to_hObject



29
30
31
# File 'lib/graph_weaver/errors.rb', line 29

def to_h
  { "error" => self.class.name, "message" => message }
end