From 3cdcfeb04b5c496199d8c88ebd2402c3db4413ab Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Tue, 3 Jan 2017 15:45:10 -0500 Subject: 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 Commit-Queue: dsinclair --- xfa/fxfa/parser/cxfa_object.cpp | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) (limited to 'xfa/fxfa/parser/cxfa_object.cpp') 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()); -- cgit v1.2.3