Class: Airtable::ORM::Http::ErrorHandler

Inherits:
Faraday::Middleware
  • Object
show all
Defined in:
lib/airtable/orm/http/error_handler.rb

Overview

Maps the whole Faraday::Error family to Airtable::ORM::ConnectionError so no Faraday type leaks past the client (rationale on the class in error.rb). Safe to catch the base: we don't enable Faraday's :raise_error, so HTTP 4xx/5xx come back as responses (→ Airtable::ORM::ApiError downstream), never raised through here. The original error is kept as #cause.

Instance Method Summary collapse

Instance Method Details

#call(env) ⇒ Object



13
14
15
16
17
# File 'lib/airtable/orm/http/error_handler.rb', line 13

def call(env)
  @app.call(env)
rescue Faraday::Error => e
  raise Airtable::ORM::ConnectionError, "Airtable request failed: #{e.class}: #{e.message}"
end