From 89d81b34db2a6cdff4d4986e8360aedda7b4e9ab Mon Sep 17 00:00:00 2001 From: Ashok Menon Date: Wed, 16 Nov 2016 15:08:40 -0800 Subject: [PATCH] Use folly for error checking Summary: Small refactor, making error checking clearer. Reviewed By: lexs Differential Revision: D4189090 fbshipit-source-id: f3a24eacfe6dd154d29662f510ce19dbe55f89a6 --- ReactCommon/cxxreact/Executor.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/ReactCommon/cxxreact/Executor.cpp b/ReactCommon/cxxreact/Executor.cpp index 15f7730b4..7e00ff164 100644 --- a/ReactCommon/cxxreact/Executor.cpp +++ b/ReactCommon/cxxreact/Executor.cpp @@ -57,14 +57,10 @@ std::unique_ptr 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( fd,