diff options
author | Stan Hu <stanhu@gmail.com> | 2016-10-18 21:26:20 -0700 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2016-10-18 21:26:20 -0700 |
commit | 47b0edbe746d5ca2a1502d3f0bf0213fe1789567 (patch) | |
tree | 8d26a1f4005849652211f408817966af3bce56e7 /app | |
parent | f64e36c44832db125beab5923c0177ff69ccedba (diff) | |
download | gitlab-ce-47b0edbe746d5ca2a1502d3f0bf0213fe1789567.tar.gz |
Improve error logging of MergeService
Relates to #23505
Diffstat (limited to 'app')
-rw-r--r-- | app/services/merge_requests/merge_service.rb | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/app/services/merge_requests/merge_service.rb b/app/services/merge_requests/merge_service.rb index b037780c431..38477c1f321 100644 --- a/app/services/merge_requests/merge_service.rb +++ b/app/services/merge_requests/merge_service.rb @@ -11,14 +11,14 @@ module MergeRequests def execute(merge_request) @merge_request = merge_request - return error('Merge request is not mergeable') unless @merge_request.mergeable? + return log_merge_error('Merge request is not mergeable', true) unless @merge_request.mergeable? merge_request.in_locked_state do if commit after_merge success else - error('Can not merge changes') + log_merge_error('Can not merge changes', true) end end end @@ -46,8 +46,8 @@ module MergeRequests merge_request.update(merge_error: e.message) false rescue StandardError => e - merge_request.update(merge_error: "Something went wrong during merge") - Rails.logger.error(e.message) + merge_request.update(merge_error: "Something went wrong during merge: #{e.message}") + log_merge_error(e.message) false ensure merge_request.update(in_progress_merge_commit_sha: nil) @@ -65,5 +65,11 @@ module MergeRequests def branch_deletion_user @merge_request.force_remove_source_branch? ? @merge_request.author : current_user end + + def log_merge_error(message, http_error = false) + Rails.logger.error("MergeService error: #{message}") + + error(message) if http_error + end end end |