Exception: Gitlab::Git::BaseError
- Inherits:
-
StandardError
- Object
- StandardError
- Gitlab::Git::BaseError
- Defined in:
- lib/gitlab/git/base_error.rb
Direct Known Subclasses
ReferenceNotFoundError, Repository::CreateTreeError, ResourceExhaustedError
Constant Summary collapse
- METADATA_KEY =
:gitaly_error_metadata
- DEBUG_ERROR_STRING_REGEX =
/(.*?) debug_error_string:.*$/m
- GRPC_CODES =
{ '0' => 'ok', '1' => 'cancelled', '2' => 'unknown', '3' => 'invalid_argument', '4' => 'deadline_exceeded', '5' => 'not_found', '6' => 'already_exists', '7' => 'permission_denied', '8' => 'resource_exhausted', '9' => 'failed_precondition', '10' => 'aborted', '11' => 'out_of_range', '12' => 'unimplemented', '13' => 'internal', '14' => 'unavailable', '15' => 'data_loss', '16' => 'unauthenticated' }.freeze
Instance Attribute Summary collapse
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#metadata ⇒ Object
readonly
Returns the value of attribute metadata.
-
#service ⇒ Object
readonly
Returns the value of attribute service.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Instance Method Summary collapse
- #build_raw_message(message) ⇒ Object
-
#initialize(msg = nil) ⇒ BaseError
constructor
A new instance of BaseError.
- #set_grpc_error_code(grpc_error) ⇒ Object
- #set_grpc_error_metadata(grpc_error) ⇒ Object
Constructor Details
#initialize(msg = nil) ⇒ BaseError
Returns a new instance of BaseError.
31 32 33 34 35 36 37 38 39 40 |
# File 'lib/gitlab/git/base_error.rb', line 31 def initialize(msg = nil) super && return if msg.nil? if msg.is_a?(::GRPC::BadStatus) set_grpc_error_code(msg) (msg) end super((msg)) end |
Instance Attribute Details
#code ⇒ Object (readonly)
Returns the value of attribute code.
29 30 31 |
# File 'lib/gitlab/git/base_error.rb', line 29 def code @code end |
#metadata ⇒ Object (readonly)
Returns the value of attribute metadata.
29 30 31 |
# File 'lib/gitlab/git/base_error.rb', line 29 def @metadata end |
#service ⇒ Object (readonly)
Returns the value of attribute service.
29 30 31 |
# File 'lib/gitlab/git/base_error.rb', line 29 def service @service end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
29 30 31 |
# File 'lib/gitlab/git/base_error.rb', line 29 def status @status end |
Instance Method Details
#build_raw_message(message) ⇒ Object
42 43 44 45 46 |
# File 'lib/gitlab/git/base_error.rb', line 42 def () = .to_s match = DEBUG_ERROR_STRING_REGEX.match() match ? match[1] : end |
#set_grpc_error_code(grpc_error) ⇒ Object
48 49 50 51 52 |
# File 'lib/gitlab/git/base_error.rb', line 48 def set_grpc_error_code(grpc_error) @status = grpc_error.code @code = GRPC_CODES[@status.to_s] @service = 'git' end |
#set_grpc_error_metadata(grpc_error) ⇒ Object
54 55 56 |
# File 'lib/gitlab/git/base_error.rb', line 54 def (grpc_error) @metadata = grpc_error..fetch(METADATA_KEY, {}).clone end |