Module: Cells::Claimable

Extended by:
ActiveSupport::Concern
Included in:
Email, GpgKey, Key, Namespace, Organizations::Organization, Project, RedirectRoute, Route, User
Defined in:
app/models/concerns/cells/claimable.rb

Constant Summary collapse

CLAIMS_BUCKET_TYPE =
Gitlab::Cells::TopologyService::Claims::V1::Bucket::Type
CLAIMS_SUBJECT_TYPE =
Gitlab::Cells::TopologyService::Claims::V1::Subject::Type
CLAIMS_SOURCE_TYPE =
Gitlab::Cells::TopologyService::Claims::V1::Source::Type
MissingPrimaryKeyError =
Class.new(RuntimeError)

Instance Method Summary collapse

Instance Method Details

#handle_grpc_error(error, value) ⇒ Object



39
40
41
42
43
44
45
46
47
48
49
50
# File 'app/models/concerns/cells/claimable.rb', line 39

def handle_grpc_error(error, value)
  case error.code
  when GRPC::Core::StatusCodes::ALREADY_EXISTS
    errors.add(unique_attribute, :taken, value: value)
  when GRPC::Core::StatusCodes::DEADLINE_EXCEEDED
    errors.add(:base, "Request timed out. Please try again.")
  when GRPC::Core::StatusCodes::NOT_FOUND
    errors.add(:base, "The requested resource does not exist.")
  else
    errors.add(:base, "An error occurred while processing your request")
  end
end