Skip to content

Commit

Permalink
Making CompiledSourceError a C enum, to keep JSBase.h as a C header
Browse files Browse the repository at this point in the history
Reviewed By: javache

Differential Revision: D4299281

fbshipit-source-id: 14cdc6d4502a70300919dc6a98a5f274076134c7
  • Loading branch information
Ashok Menon authored and Facebook Github Bot committed Dec 9, 2016
1 parent 1642b38 commit 3021375
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions ReactCommon/cxxreact/JSCExecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -382,23 +382,25 @@ void JSCExecutor::loadApplicationScript(
JSCompiledSourceError jsError;
auto bcSourceCode = JSCreateCompiledSourceCode(fd, jsSourceURL, &jsError);

if (jsError == JSCompiledSourceErrorOnRead ||
jsError == JSCompiledSourceErrorNotCompiled) {
switch (jsError) {
case JSCompiledSourceErrorOnRead:
case JSCompiledSourceErrorNotCompiled:
// Not bytecode, fall through.
return JSExecutor::loadApplicationScript(fd, sourceURL);
} else if (jsError == JSCompiledSourceErrorVersionMismatch) {

case JSCompiledSourceErrorVersionMismatch:
throw std::runtime_error("Compiled Source Version Mismatch");
}

folly::throwOnFail<std::runtime_error>(
jsError == JSCompiledSourceErrorNone,
"Unhandled Compiled Source Error"
);
case JSCompiledSourceErrorNone:
folly::throwOnFail<std::runtime_error>(
bcSourceCode != nullptr,
"Unexpected error opening compiled bundle"
);
break;

folly::throwOnFail<std::runtime_error>(
bcSourceCode != nullptr,
"Unexpected error opening compiled bundle"
);
default:
throw std::runtime_error("Unhandled Compiled Source Error");
}

ReactMarker::logMarker("RUN_JS_BUNDLE_START");

Expand Down

0 comments on commit 3021375

Please sign in to comment.