Commit 155eba0e authored by Jan Provaznik's avatar Jan Provaznik

Merge branch 'sh-fix-jira-error-message' into 'master'

Make error logging fields consistent in failed JIRA requests

See merge request gitlab-org/gitlab!44759
parents 4642bb81 a07824d2
...@@ -40,7 +40,12 @@ module Jira ...@@ -40,7 +40,12 @@ module Jira
build_service_response(response) build_service_response(response)
rescue Timeout::Error, Errno::EINVAL, Errno::ECONNRESET, Errno::ECONNREFUSED, URI::InvalidURIError, JIRA::HTTPError, OpenSSL::SSL::SSLError => error rescue Timeout::Error, Errno::EINVAL, Errno::ECONNRESET, Errno::ECONNREFUSED, URI::InvalidURIError, JIRA::HTTPError, OpenSSL::SSL::SSLError => error
error_message = "Jira request error: #{error.message}" error_message = "Jira request error: #{error.message}"
log_error("Error sending message", client_url: client.options[:site], error: error_message) log_error("Error sending message", client_url: client.options[:site],
error: {
exception_class: error.class.name,
exception_message: error.message,
exception_backtrace: Gitlab::BacktraceCleaner.clean_backtrace(error.backtrace)
})
ServiceResponse.error(message: error_message) ServiceResponse.error(message: error_message)
end end
......
...@@ -45,6 +45,10 @@ RSpec.describe Jira::Requests::Projects::ListService do ...@@ -45,6 +45,10 @@ RSpec.describe Jira::Requests::Projects::ListService do
end end
it 'returns an error response' do it 'returns an error response' do
expect(Gitlab::ProjectServiceLogger).to receive(:error).with(
hash_including(
error: hash_including(:exception_class, :exception_message, :exception_backtrace)))
.and_call_original
expect(subject.error?).to be_truthy expect(subject.error?).to be_truthy
expect(subject.message).to eq('Jira request error: Timeout::Error') expect(subject.message).to eq('Jira request error: Timeout::Error')
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