in src/api_proxy/service_control/check_response_convert_utils.cc [152:201]
Status ConvertAllocateQuotaResponse(
const ::google::api::servicecontrol::v1::AllocateQuotaResponse& response,
const std::string&, QuotaResponseInfo* quota_response_info) {
// response.operation_id()
if (response.allocate_errors().empty()) {
return OkStatus();
}
const ::google::api::servicecontrol::v1::QuotaError& error =
response.allocate_errors().Get(0);
quota_response_info->error = {QuotaError_Code_Name(error.code()),
/*is_network_error=*/false,
ScResponseErrorType::ERROR_TYPE_UNSPECIFIED};
ScResponseError& quota_error = quota_response_info->error;
switch (error.code()) {
case ::google::api::servicecontrol::v1::QuotaError::UNSPECIFIED:
// This is never used.
break;
case ::google::api::servicecontrol::v1::QuotaError::RESOURCE_EXHAUSTED:
// Quota allocation failed.
// Same as [google.rpc.Code.RESOURCE_EXHAUSTED][].
quota_error.type = ScResponseErrorType::CONSUMER_QUOTA;
return Status(StatusCode::kResourceExhausted, error.description());
case ::google::api::servicecontrol::v1::QuotaError::BILLING_NOT_ACTIVE:
// Consumer cannot access the service because billing is disabled.
quota_error.type = ScResponseErrorType::CONSUMER_ERROR;
return Status(StatusCode::kPermissionDenied, error.description());
case ::google::api::servicecontrol::v1::QuotaError::PROJECT_DELETED:
// Consumer's project has been marked as deleted (soft deletion).
quota_error.type = ScResponseErrorType::CONSUMER_ERROR;
return Status(StatusCode::kInvalidArgument, error.description());
case ::google::api::servicecontrol::v1::QuotaError::API_KEY_INVALID:
// Specified API key is invalid.
case ::google::api::servicecontrol::v1::QuotaError::API_KEY_EXPIRED:
// Specified API Key has expired.
quota_error.type = ScResponseErrorType::API_KEY_INVALID;
return Status(StatusCode::kInvalidArgument, error.description());
default:
return Status(StatusCode::kInternal, error.description());
}
return OkStatus();
}