Class: Anthropic::MiddlewareErrors
- Inherits:
-
Faraday::Middleware
- Object
- Faraday::Middleware
- Anthropic::MiddlewareErrors
- Defined in:
- lib/anthropic.rb
Instance Method Summary collapse
Instance Method Details
#call(env) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/anthropic.rb', line 13 def call(env) @app.call(env) rescue Faraday::Error => e raise e unless e.response.is_a?(Hash) logger = Logger.new($stdout) logger.formatter = proc do |_severity, _datetime, _progname, msg| "\033[31mAnthropic HTTP Error (spotted in ruby-anthropic #{VERSION}): #{msg}\n\033[0m" end logger.error(e.response[:body]) raise e end |