Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'lib/gitlab/git/base_error.rb')
-rw-r--r--lib/gitlab/git/base_error.rb12
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/gitlab/git/base_error.rb b/lib/gitlab/git/base_error.rb
index 0b0fdef54cc..330e947844c 100644
--- a/lib/gitlab/git/base_error.rb
+++ b/lib/gitlab/git/base_error.rb
@@ -4,6 +4,7 @@ require 'grpc'
module Gitlab
module Git
class BaseError < StandardError
+ METADATA_KEY = :gitaly_error_metadata
DEBUG_ERROR_STRING_REGEX = /(.*?) debug_error_string:.*$/m.freeze
GRPC_CODES = {
'0' => 'ok',
@@ -25,12 +26,15 @@ module Gitlab
'16' => 'unauthenticated'
}.freeze
- attr_reader :status, :code, :service
+ attr_reader :status, :code, :service, :metadata
def initialize(msg = nil)
super && return if msg.nil?
- set_grpc_error_code(msg) if msg.is_a?(::GRPC::BadStatus)
+ if msg.is_a?(::GRPC::BadStatus)
+ set_grpc_error_code(msg)
+ set_grpc_error_metadata(msg)
+ end
super(build_raw_message(msg))
end
@@ -46,6 +50,10 @@ module Gitlab
@code = GRPC_CODES[@status.to_s]
@service = 'git'
end
+
+ def set_grpc_error_metadata(grpc_error)
+ @metadata = grpc_error.metadata.fetch(METADATA_KEY, {}).clone
+ end
end
end
end