Commit 0342a849 authored by Markus Koller's avatar Markus Koller

Merge branch 'sh-log-create-commit-exceptions' into 'master'

Log exceptions in Commits::CreateService

See merge request gitlab-org/gitlab!34365
parents 5872e6cb 649c7ca8
......@@ -30,12 +30,14 @@ module Commits
success(result: new_commit)
rescue ChangeError => ex
Gitlab::ErrorTracking.log_exception(ex)
error(ex.message, pass_back: { error_code: ex.error_code })
rescue ValidationError,
Gitlab::Git::Index::IndexError,
Gitlab::Git::CommitError,
Gitlab::Git::PreReceiveError,
Gitlab::Git::CommandError => ex
Gitlab::ErrorTracking.log_exception(ex)
error(ex.message)
end
......
......@@ -24,6 +24,8 @@ RSpec.describe Commits::CreateService do
subject(:result) { service.execute }
it 'raises an error if the repositoy exceeds the size limit' do
expect(Gitlab::ErrorTracking).to receive(:log_exception)
.with(instance_of(Commits::CreateService::ValidationError)).and_call_original
expect(result[:status]).to be(:error)
expect(result[:message]).to eq('Your changes could not be committed, because this repository has exceeded its size limit of 1 Byte by 1 Byte')
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