class OpenAI::MiddlewareErrors
def call(env)
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[31mOpenAI HTTP Error (spotted in ruby-openai #{VERSION}): #{msg}\n\033[0m" end logger.error(e.response[:body]) raise e end