summaryrefslogtreecommitdiff
path: root/lib/gitlab/git/wraps_gitaly_errors.rb
blob: 1d34f3c8eb2ad4eb17de2b57238426de9f032949 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# frozen_string_literal: true

module Gitlab
  module Git
    module WrapsGitalyErrors
      def wrapped_gitaly_errors(&block)
        yield block
      rescue GRPC::NotFound => e
        raise Gitlab::Git::Repository::NoRepository, e
      rescue GRPC::InvalidArgument => e
        raise ArgumentError, e
      rescue GRPC::DeadlineExceeded => e
        raise Gitlab::Git::CommandTimedOut, e
      rescue GRPC::BadStatus => e
        raise Gitlab::Git::CommandError, e
      end
    end
  end
end