Commit 946e0078 authored by Alper Akgun's avatar Alper Akgun

Merge branch 'sh-add-http-status-lfs-push-service' into 'master'

Add HTTP status to LFS push client error messages

See merge request gitlab-org/gitlab!77334
parents 549f5a74 4e1acedb
......@@ -36,7 +36,7 @@ module Gitlab
headers: build_request_headers
)
raise BatchSubmitError unless rsp.success?
raise BatchSubmitError.new(http_response: rsp) unless rsp.success?
# HTTParty provides rsp.parsed_response, but it only kicks in for the
# application/json content type in the response, which we can't rely on
......@@ -65,7 +65,7 @@ module Gitlab
rsp = Gitlab::HTTP.put(upload_action['href'], params)
raise ObjectUploadError unless rsp.success?
raise ObjectUploadError.new(http_response: rsp) unless rsp.success?
ensure
file&.close
end
......@@ -81,7 +81,7 @@ module Gitlab
rsp = Gitlab::HTTP.post(verify_action['href'], params)
raise ObjectVerifyError unless rsp.success?
raise ObjectVerifyError.new(http_response: rsp) unless rsp.success?
end
private
......@@ -105,9 +105,21 @@ module Gitlab
{ username: credentials[:user], password: credentials[:password] }
end
class BatchSubmitError < StandardError
class HttpError < StandardError
def initialize(http_response:)
super
@http_response = http_response
end
def http_error
"HTTP status #{@http_response.code}"
end
end
class BatchSubmitError < HttpError
def message
"Failed to submit batch"
"Failed to submit batch: #{http_error}"
end
end
......@@ -122,15 +134,15 @@ module Gitlab
end
end
class ObjectUploadError < StandardError
class ObjectUploadError < HttpError
def message
"Failed to upload object"
"Failed to upload object: #{http_error}"
end
end
class ObjectVerifyError < StandardError
class ObjectVerifyError < HttpError
def message
"Failed to verify object"
"Failed to verify object: #{http_error}"
end
end
end
......
......@@ -159,7 +159,7 @@ RSpec.describe Gitlab::Lfs::Client do
it 'raises an error' do
stub_upload(object: object, headers: upload_action['header']).to_return(status: 400)
expect { lfs_client.upload!(object, upload_action, authenticated: true) }.to raise_error(/Failed/)
expect { lfs_client.upload!(object, upload_action, authenticated: true) }.to raise_error(/Failed to upload object: HTTP status 400/)
end
end
......@@ -167,7 +167,7 @@ RSpec.describe Gitlab::Lfs::Client do
it 'raises an error' do
stub_upload(object: object, headers: upload_action['header']).to_return(status: 500)
expect { lfs_client.upload!(object, upload_action, authenticated: true) }.to raise_error(/Failed/)
expect { lfs_client.upload!(object, upload_action, authenticated: true) }.to raise_error(/Failed to upload object: HTTP status 500/)
end
end
......@@ -226,7 +226,7 @@ RSpec.describe Gitlab::Lfs::Client do
it 'raises an error' do
stub_verify(object: object, headers: verify_action['header']).to_return(status: 400)
expect { lfs_client.verify!(object, verify_action, authenticated: true) }.to raise_error(/Failed/)
expect { lfs_client.verify!(object, verify_action, authenticated: true) }.to raise_error(/Failed to verify object: HTTP status 400/)
end
end
......@@ -234,7 +234,7 @@ RSpec.describe Gitlab::Lfs::Client do
it 'raises an error' do
stub_verify(object: object, headers: verify_action['header']).to_return(status: 500)
expect { lfs_client.verify!(object, verify_action, authenticated: true) }.to raise_error(/Failed/)
expect { lfs_client.verify!(object, verify_action, authenticated: true) }.to raise_error(/Failed to verify object: HTTP status 500/)
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