Switch CHECK to a status in resource handling code. Expand error message.

PiperOrigin-RevId: 483438131
This commit is contained in:
MediaPipe Team 2022-10-24 11:25:18 -07:00 committed by Copybara-Service
parent 2cf9523468
commit 3d88b1797a
2 changed files with 4 additions and 2 deletions

View File

@ -82,7 +82,8 @@ absl::StatusOr<std::string> PathToResourceAsFile(const std::string& path) {
// If that fails, assume it was a relative path, and try just the base name.
{
const size_t last_slash_idx = path.find_last_of("\\/");
CHECK_NE(last_slash_idx, std::string::npos); // Make sure it's a path.
RET_CHECK(last_slash_idx != std::string::npos)
<< path << " doesn't have a slash in it"; // Make sure it's a path.
auto base_name = path.substr(last_slash_idx + 1);
auto status_or_path = PathToResourceAsFileInternal(base_name);
if (status_or_path.ok()) {

View File

@ -71,7 +71,8 @@ absl::StatusOr<std::string> PathToResourceAsFile(const std::string& path) {
// If that fails, assume it was a relative path, and try just the base name.
{
const size_t last_slash_idx = path.find_last_of("\\/");
CHECK_NE(last_slash_idx, std::string::npos); // Make sure it's a path.
RET_CHECK(last_slash_idx != std::string::npos)
<< path << " doesn't have a slash in it"; // Make sure it's a path.
auto base_name = path.substr(last_slash_idx + 1);
auto status_or_path = PathToResourceAsFileInternal(base_name);
if (status_or_path.ok()) {