Exception: GraphWeaver::Error

Inherits:
StandardError
  • Object
show all
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), ValidationError (build time) — each merging its specifics into #to_h.

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Error

every GraphWeaver error surfaces on the logger too (see GraphWeaver.logger) — construction here means a raise



20
21
22
23
# File 'lib/graph_weaver/errors.rb', line 20

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

Instance Method Details

#to_hObject



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

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