Convert JS execute methods to return Optional<IJS_Runtime::JS_Error>
This CL changes several of the JS execution methods to to return an
Optional<IJS_Runtime::JS_Error> instead of a bool with a WideString
out param.
The IJS_Runtime::JS_Error will contain the line, column and exception message
if an error occurs during execution.
Change-Id: I37785ae6cd133a4c94ad8d25289473600b8a5d19
Reviewed-on: https://pdfium-review.googlesource.com/32614
Commit-Queue: dsinclair <dsinclair@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
diff --git a/fxjs/cjs_runtime.cpp b/fxjs/cjs_runtime.cpp
index f6e7b2d..b47c595 100644
--- a/fxjs/cjs_runtime.cpp
+++ b/fxjs/cjs_runtime.cpp
@@ -190,14 +190,9 @@
return m_pFormFillEnv.Get();
}
-int CJS_Runtime::ExecuteScript(const WideString& script, WideString* info) {
- FXJSErr error = {};
- int nRet = Execute(script, &error);
- if (nRet < 0) {
- *info = WideString::Format(L"[ Line: %05d { %ls } ] : %s", error.linnum - 1,
- error.srcline, error.message);
- }
- return nRet;
+Optional<IJS_Runtime::JS_Error> CJS_Runtime::ExecuteScript(
+ const WideString& script) {
+ return Execute(script);
}
bool CJS_Runtime::AddEventToSet(const FieldEvent& event) {