Raise a better error message when a DescriptorPool lookup fails because of a missing BUILD dep.

PiperOrigin-RevId: 309445470
Change-Id: If45fc4919f424c249c4cb31a3eb4cd2e0be8c7d4
This commit is contained in:
Saurabh Saxena 2020-05-01 11:47:03 -07:00 committed by TensorFlower Gardener
parent eb44e1a63d
commit 70d4dfe314

View File

@ -68,14 +68,18 @@ Status GetDescriptorPoolFromBinary(
const string& source,
std::unique_ptr<protobuf::DescriptorPool>* owned_desc_pool) {
if (!absl::StartsWith(source, "bytes://")) {
return errors::InvalidArgument(
"Source does not represent serialized file descriptor set proto.");
return errors::InvalidArgument(absl::StrCat(
"Source does not represent serialized file descriptor set proto. ",
"This may be due to a missing dependency on the file containing ",
"REGISTER_DESCRIPTOR_POOL(\"", source, "\", ...);"));
}
// Parse the FileDescriptorSet.
protobuf::FileDescriptorSet proto;
if (!proto.ParseFromString(string(absl::StripPrefix(source, "bytes://")))) {
return errors::InvalidArgument(
"Source does not represent serialized file descriptor set proto.");
return errors::InvalidArgument(absl::StrCat(
"Source does not represent serialized file descriptor set proto. ",
"This may be due to a missing dependency on the file containing ",
"REGISTER_DESCRIPTOR_POOL(\"", source, "\", ...);"));
}
return CreatePoolFromSet(proto, owned_desc_pool);
}