Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: src/FileSystemJsObject.cpp

Issue 29812649: Issue 6526 - *ToV8String() return MaybeLocal<> and check Call() return value (Closed) Base URL: https://hg.adblockplus.org/libadblockplus/
Patch Set: Added tests. Renamed CHECKED_TO_LOCAL. Created July 11, 2018, 2:10 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/JsEngine.cpp » ('j') | src/Utils.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/FileSystemJsObject.cpp
===================================================================
--- a/src/FileSystemJsObject.cpp
+++ b/src/FileSystemJsObject.cpp
@@ -182,20 +182,26 @@
auto isolate = jsEngine->GetIsolate();
const v8::TryCatch tryCatch(isolate);
const auto contentEnd = content.cend();
auto stringBegin = SkipEndOfLine(content.begin(), contentEnd);
auto v8Context = isolate->GetCurrentContext();
do
{
auto stringEnd = AdvanceToEndOfLine(stringBegin, contentEnd);
- auto jsLine = Utils::StringBufferToV8String(isolate, StringBuffer(stringBegin, stringEnd)).As<v8::Value>();
- processFunc->Call(v8Context, globalContext, 1, &jsLine);
- if (tryCatch.HasCaught())
- throw JsError(isolate, tryCatch.Exception(), tryCatch.Message());
+ auto jsLine = CHECKED_TO_LOCAL_WITH_TRY_CATCH(
+ isolate,
+ Utils::StringBufferToV8String(
+ isolate, StringBuffer(stringBegin, stringEnd)),
+ tryCatch).As<v8::Value>();
+
+ CHECKED_TO_LOCAL_WITH_TRY_CATCH(
+ isolate, processFunc->Call(v8Context, globalContext, 1, &jsLine),
+ tryCatch);
+
stringBegin = SkipEndOfLine(stringEnd, contentEnd);
} while (stringBegin != contentEnd);
jsEngine->GetJsValues(weakData->weakResolveCallback)[0].Call();
}, [weakData](const std::string& error)
{
if (error.empty())
return;
auto jsEngine = weakData->weakJsEngine.lock();
« no previous file with comments | « no previous file | src/JsEngine.cpp » ('j') | src/Utils.h » ('J')

Powered by Google App Engine
This is Rietveld