summaryrefslogtreecommitdiff
path: root/xfa/fxfa/parser/cxfa_object.cpp
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2017-01-03 15:45:10 -0500
committerChromium commit bot <commit-bot@chromium.org>2017-01-03 21:08:58 +0000
commit3cdcfeb04b5c496199d8c88ebd2402c3db4413ab (patch)
treeabab4708b78aae2bec75ae6d1e9446aec863d159 /xfa/fxfa/parser/cxfa_object.cpp
parente8f6897c2a80242217da785318b427c82c00ad40 (diff)
downloadpdfium-3cdcfeb04b5c496199d8c88ebd2402c3db4413ab.tar.xz
Create individual exception methods.
This CL removes the LoadString method from CPDFXFA_Context and, instead, creates individual exception methods for each of the loaded strings and calls as needed. BUG=pdfium:549 Change-Id: I1d975f01f13f45a885946a9952f24b13387dc3e4 Reviewed-on: https://pdfium-review.googlesource.com/2135 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'xfa/fxfa/parser/cxfa_object.cpp')
-rw-r--r--xfa/fxfa/parser/cxfa_object.cpp27
1 files changed, 21 insertions, 6 deletions
diff --git a/xfa/fxfa/parser/cxfa_object.cpp b/xfa/fxfa/parser/cxfa_object.cpp
index c8ed7138a8..45e34424aa 100644
--- a/xfa/fxfa/parser/cxfa_object.cpp
+++ b/xfa/fxfa/parser/cxfa_object.cpp
@@ -39,7 +39,7 @@ void CXFA_Object::Script_ObjectClass_ClassName(CFXJSE_Value* pValue,
bool bSetting,
XFA_ATTRIBUTE eAttribute) {
if (bSetting) {
- ThrowException(XFA_IDS_INVAlID_PROP_SET);
+ ThrowInvalidPropertyException();
return;
}
CFX_WideStringC className = GetClassName();
@@ -47,14 +47,29 @@ void CXFA_Object::Script_ObjectClass_ClassName(CFXJSE_Value* pValue,
FX_UTF8Encode(className.c_str(), className.GetLength()).AsStringC());
}
-void CXFA_Object::ThrowException(int32_t iStringID, ...) {
- IXFA_AppProvider* pAppProvider = m_pDocument->GetNotify()->GetAppProvider();
- ASSERT(pAppProvider);
+void CXFA_Object::ThrowInvalidPropertyException() const {
+ ThrowException(L"Invalid property set operation.");
+}
+
+void CXFA_Object::ThrowIndexOutOfBoundsException() const {
+ ThrowException(L"Index value is out of bounds.");
+}
+
+void CXFA_Object::ThrowParamCountMismatchException(
+ const CFX_WideString& method) const {
+ ThrowException(L"Incorrect number of parameters calling method '%s'.",
+ method.c_str());
+}
+
+void CXFA_Object::ThrowArgumentMismatchException() const {
+ ThrowException(L"Argument mismatch in property or function argument.");
+}
+void CXFA_Object::ThrowException(const FX_WCHAR* str, ...) const {
CFX_WideString wsMessage;
va_list arg_ptr;
- va_start(arg_ptr, iStringID);
- wsMessage.FormatV(pAppProvider->LoadString(iStringID).c_str(), arg_ptr);
+ va_start(arg_ptr, str);
+ wsMessage.FormatV(str, arg_ptr);
va_end(arg_ptr);
FXJSE_ThrowMessage(
FX_UTF8Encode(wsMessage.c_str(), wsMessage.GetLength()).AsStringC());