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/fpdfsdk/cpdfsdk_interform.cpp b/fpdfsdk/cpdfsdk_interform.cpp
index 4f11bab..b37562c 100644
--- a/fpdfsdk/cpdfsdk_interform.cpp
+++ b/fpdfsdk/cpdfsdk_interform.cpp
@@ -291,10 +291,9 @@
bool bRC = true;
pContext->OnField_Calculate(pFormField, pField, sValue, bRC);
- WideString sInfo;
- bool bRet = pContext->RunScript(csJS, &sInfo);
+ Optional<IJS_Runtime::JS_Error> err = pContext->RunScript(csJS);
pRuntime->ReleaseEventContext(pContext);
- if (bRet && bRC && sValue.Compare(sOldValue) != 0)
+ if (!err && bRC && sValue.Compare(sOldValue) != 0)
pField->SetValue(sValue, true);
}
m_bBusy = false;
@@ -328,10 +327,10 @@
IJS_EventContext* pContext = pRuntime->NewEventContext();
pContext->OnField_Format(pFormField, Value, true);
- WideString sInfo;
- bool bRet = pContext->RunScript(script, &sInfo);
+
+ Optional<IJS_Runtime::JS_Error> err = pContext->RunScript(script);
pRuntime->ReleaseEventContext(pContext);
- if (bRet) {
+ if (!err) {
sValue = Value;
bFormatted = true;
}