Commit cbf6fe66 authored by David Fernandez's avatar David Fernandez

Apply backend maintainer feedback

parent 9110a745
......@@ -176,7 +176,7 @@ module ContainerRegistry
yield(conn) if block_given?
conn.request(:retry, RETRY_OPTIONS)
conn.request(:error_callback, ERROR_CALLBACK_OPTIONS)
conn.request(:gitlab_error_callback, ERROR_CALLBACK_OPTIONS)
conn.adapter :net_http
end
......@@ -226,7 +226,7 @@ module ContainerRegistry
conn.request :json
conn.request(:retry, RETRY_OPTIONS)
conn.request(:error_callback, ERROR_CALLBACK_OPTIONS)
conn.request(:gitlab_error_callback, ERROR_CALLBACK_OPTIONS)
conn.adapter :net_http
end
end
......
......@@ -2,6 +2,6 @@
module Gitlab
module Faraday
::Faraday::Request.register_middleware(error_callback: -> { ::Gitlab::Faraday::ErrorCallback })
::Faraday::Request.register_middleware(gitlab_error_callback: -> { ::Gitlab::Faraday::ErrorCallback })
end
end
......@@ -29,15 +29,14 @@ module Gitlab
def call(env)
@app.call(env)
rescue => e
@options.callback.call(env, e)
@options.callback&.call(env, e)
raise
end
class Options < ::Faraday::Options.new(:callback)
DEFAULT_CALLBACK = -> (_env, _exception) { }
def callback
self[:callback] || DEFAULT_CALLBACK
self[:callback]
end
end
end
......
......@@ -26,8 +26,6 @@ RSpec.describe Gitlab::Faraday::ErrorCallback do
context 'with no callback' do
it 'uses the default callback' do
expect(Gitlab::Faraday::ErrorCallback::Options::DEFAULT_CALLBACK).to receive(:call).and_call_original
expect { subject }.to raise_error(ArgumentError, 'Kaboom!')
end
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment