Use folly for error checking

Summary: Small refactor, making error checking clearer.

Reviewed By: lexs

Differential Revision: D4189090

fbshipit-source-id: f3a24eacfe6dd154d29662f510ce19dbe55f89a6
This commit is contained in:
Ashok Menon 2016-11-16 15:08:40 -08:00 committed by Facebook Github Bot
parent f22dfa3efb
commit 89d81b34db
1 changed files with 2 additions and 6 deletions

View File

@ -57,14 +57,10 @@ std::unique_ptr<const JSBigMmapString> JSBigMmapString::fromOptimizedBundle(
{
auto sourcePath = bundlePath + UNPACKED_JS_SOURCE_PATH_SUFFIX;
fd = ::open(sourcePath.c_str(), O_RDONLY);
if (fd == -1) {
throw std::runtime_error(std::string("could not open js bundle file: ") + ::strerror(errno));
}
folly::checkUnixError(fd, "could not open js bundle file.");
}
if (::fstat(fd, &fileInfo)) {
throw std::runtime_error(std::string("fstat on js bundle failed: ") + strerror(errno));
}
folly::checkUnixError(::fstat(fd, &fileInfo), "fstat on js bundle failed.");
return folly::make_unique<const JSBigMmapString>(
fd,