Commit cbf6fe66 authored by David Fernandez's avatar David Fernandez

Apply backend maintainer feedback

parent 9110a745
...@@ -176,7 +176,7 @@ module ContainerRegistry ...@@ -176,7 +176,7 @@ module ContainerRegistry
yield(conn) if block_given? yield(conn) if block_given?
conn.request(:retry, RETRY_OPTIONS) conn.request(:retry, RETRY_OPTIONS)
conn.request(:error_callback, ERROR_CALLBACK_OPTIONS) conn.request(:gitlab_error_callback, ERROR_CALLBACK_OPTIONS)
conn.adapter :net_http conn.adapter :net_http
end end
...@@ -226,7 +226,7 @@ module ContainerRegistry ...@@ -226,7 +226,7 @@ module ContainerRegistry
conn.request :json conn.request :json
conn.request(:retry, RETRY_OPTIONS) conn.request(:retry, RETRY_OPTIONS)
conn.request(:error_callback, ERROR_CALLBACK_OPTIONS) conn.request(:gitlab_error_callback, ERROR_CALLBACK_OPTIONS)
conn.adapter :net_http conn.adapter :net_http
end end
end end
......
...@@ -2,6 +2,6 @@ ...@@ -2,6 +2,6 @@
module Gitlab module Gitlab
module Faraday module Faraday
::Faraday::Request.register_middleware(error_callback: -> { ::Gitlab::Faraday::ErrorCallback }) ::Faraday::Request.register_middleware(gitlab_error_callback: -> { ::Gitlab::Faraday::ErrorCallback })
end end
end end
...@@ -29,15 +29,14 @@ module Gitlab ...@@ -29,15 +29,14 @@ module Gitlab
def call(env) def call(env)
@app.call(env) @app.call(env)
rescue => e rescue => e
@options.callback.call(env, e) @options.callback&.call(env, e)
raise raise
end end
class Options < ::Faraday::Options.new(:callback) class Options < ::Faraday::Options.new(:callback)
DEFAULT_CALLBACK = -> (_env, _exception) { }
def callback def callback
self[:callback] || DEFAULT_CALLBACK self[:callback]
end end
end end
end end
......
...@@ -26,8 +26,6 @@ RSpec.describe Gitlab::Faraday::ErrorCallback do ...@@ -26,8 +26,6 @@ RSpec.describe Gitlab::Faraday::ErrorCallback do
context 'with no callback' do context 'with no callback' do
it 'uses the default 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!') expect { subject }.to raise_error(ArgumentError, 'Kaboom!')
end end
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