Commit 217955dd authored by Douglas Barbosa Alexandre's avatar Douglas Barbosa Alexandre

Merge branch 'tweak-webhook-service-exceptions' into 'master'

Use defined HTTP errors in WebHookService

See merge request gitlab-org/gitlab!62020
parents 50a50729 ae3d250a
...@@ -69,8 +69,7 @@ class WebHookService ...@@ -69,8 +69,7 @@ class WebHookService
http_status: response.code, http_status: response.code,
message: response.to_s message: response.to_s
} }
rescue SocketError, OpenSSL::SSL::SSLError, Errno::ECONNRESET, Errno::ECONNREFUSED, Errno::EHOSTUNREACH, rescue *Gitlab::HTTP::HTTP_ERRORS,
Net::OpenTimeout, Net::ReadTimeout, Gitlab::HTTP::BlockedUrlError, Gitlab::HTTP::RedirectionTooDeep,
Gitlab::Json::LimitedEncoder::LimitExceeded, URI::InvalidURIError => e Gitlab::Json::LimitedEncoder::LimitExceeded, URI::InvalidURIError => e
execution_duration = Gitlab::Metrics::System.monotonic_time - start_time execution_duration = Gitlab::Metrics::System.monotonic_time - start_time
log_execution( log_execution(
......
...@@ -128,11 +128,10 @@ RSpec.describe WebHookService do ...@@ -128,11 +128,10 @@ RSpec.describe WebHookService do
end end
it 'handles exceptions' do it 'handles exceptions' do
exceptions = [ exceptions = Gitlab::HTTP::HTTP_ERRORS + [
SocketError, OpenSSL::SSL::SSLError, Errno::ECONNRESET, Errno::ECONNREFUSED, Gitlab::Json::LimitedEncoder::LimitExceeded, URI::InvalidURIError
Errno::EHOSTUNREACH, Net::OpenTimeout, Net::ReadTimeout,
Gitlab::HTTP::BlockedUrlError, Gitlab::HTTP::RedirectionTooDeep
] ]
exceptions.each do |exception_class| exceptions.each do |exception_class|
exception = exception_class.new('Exception message') exception = exception_class.new('Exception message')
project_hook.enable! project_hook.enable!
......
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