Remove WideString::Format() from ThrowException() methods.

No need for variadic printf-like functions, since callers can cobble
arguments into a string much more simply.

Change-Id: I0e8d6f6a55a3715ef9d5c6940b73ce8bb2220a1a
Reviewed-on: https://pdfium-review.googlesource.com/39611
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
diff --git a/fxjs/cfxjse_formcalc_context.cpp b/fxjs/cfxjse_formcalc_context.cpp
index 4201059..9973df6 100644
--- a/fxjs/cfxjse_formcalc_context.cpp
+++ b/fxjs/cfxjse_formcalc_context.cpp
@@ -6199,8 +6199,8 @@
 
 void CFXJSE_FormCalcContext::ThrowNoDefaultPropertyException(
     const ByteStringView& name) const {
-  ThrowException(L"%ls doesn't have a default property.",
-                 WideString::FromUTF8(name).c_str());
+  ThrowException(WideString::FromUTF8(name) +
+                 L" doesn't have a default property.");
 }
 
 void CFXJSE_FormCalcContext::ThrowCompilerErrorException() const {
@@ -6218,28 +6218,21 @@
 void CFXJSE_FormCalcContext::ThrowPropertyNotInObjectException(
     const WideString& name,
     const WideString& exp) const {
-  ThrowException(
-      L"An attempt was made to reference property '%ls' of a non-object "
-      L"in SOM expression %ls.",
-      name.c_str(), exp.c_str());
+  ThrowException(L"An attempt was made to reference property '" + name +
+                 L"' of a non-object in SOM expression " + exp + L".");
 }
 
 void CFXJSE_FormCalcContext::ThrowParamCountMismatchException(
     const WideString& method) const {
-  ThrowException(L"Incorrect number of parameters calling method '%ls'.",
-                 method.c_str());
+  ThrowException(L"Incorrect number of parameters calling method '" + method +
+                 L"'.");
 }
 
 void CFXJSE_FormCalcContext::ThrowArgumentMismatchException() const {
   ThrowException(L"Argument mismatch in property or function argument.");
 }
 
-void CFXJSE_FormCalcContext::ThrowException(const wchar_t* str, ...) const {
-  va_list arg_ptr;
-  va_start(arg_ptr, str);
-  WideString wsMessage = WideString::FormatV(str, arg_ptr);
-  va_end(arg_ptr);
-
-  ASSERT(!wsMessage.IsEmpty());
-  FXJSE_ThrowMessage(wsMessage.UTF8Encode().AsStringView());
+void CFXJSE_FormCalcContext::ThrowException(const WideString& str) const {
+  ASSERT(!str.IsEmpty());
+  FXJSE_ThrowMessage(str.UTF8Encode().AsStringView());
 }
diff --git a/fxjs/cfxjse_formcalc_context.h b/fxjs/cfxjse_formcalc_context.h
index e95cc5f..ef1cd34 100644
--- a/fxjs/cfxjse_formcalc_context.h
+++ b/fxjs/cfxjse_formcalc_context.h
@@ -399,7 +399,7 @@
                                          const WideString& exp) const;
   void ThrowArgumentMismatchException() const;
   void ThrowParamCountMismatchException(const WideString& method) const;
-  void ThrowException(const wchar_t* str, ...) const;
+  void ThrowException(const WideString& str) const;
 
   UnownedPtr<v8::Isolate> m_pIsolate;
   CFXJSE_Class* m_pFMClass;
diff --git a/fxjs/xfa/cjx_object.cpp b/fxjs/xfa/cjx_object.cpp
index 23e754d..8684212 100644
--- a/fxjs/xfa/cjx_object.cpp
+++ b/fxjs/xfa/cjx_object.cpp
@@ -178,9 +178,8 @@
 }
 
 void CJX_Object::ThrowTooManyOccurancesException(const WideString& obj) const {
-  ThrowException(
-      L"The element [%ls] has violated its allowable number of occurrences.",
-      obj.c_str());
+  ThrowException(L"The element [" + obj +
+                 L"] has violated its allowable number of occurrences.");
 }
 
 void CJX_Object::ThrowInvalidPropertyException() const {
@@ -193,22 +192,17 @@
 
 void CJX_Object::ThrowParamCountMismatchException(
     const WideString& method) const {
-  ThrowException(L"Incorrect number of parameters calling method '%ls'.",
-                 method.c_str());
+  ThrowException(L"Incorrect number of parameters calling method '" + method +
+                 L"'.");
 }
 
 void CJX_Object::ThrowArgumentMismatchException() const {
   ThrowException(L"Argument mismatch in property or function argument.");
 }
 
-void CJX_Object::ThrowException(const wchar_t* str, ...) const {
-  va_list arg_ptr;
-  va_start(arg_ptr, str);
-  WideString wsMessage = WideString::FormatV(str, arg_ptr);
-  va_end(arg_ptr);
-
-  ASSERT(!wsMessage.IsEmpty());
-  FXJSE_ThrowMessage(wsMessage.UTF8Encode().AsStringView());
+void CJX_Object::ThrowException(const WideString& str) const {
+  ASSERT(!str.IsEmpty());
+  FXJSE_ThrowMessage(str.UTF8Encode().AsStringView());
 }
 
 bool CJX_Object::HasAttribute(XFA_Attribute eAttr) {
diff --git a/fxjs/xfa/cjx_object.h b/fxjs/xfa/cjx_object.h
index c9042b5..4116f37 100644
--- a/fxjs/xfa/cjx_object.h
+++ b/fxjs/xfa/cjx_object.h
@@ -222,7 +222,7 @@
   void DefineMethods(pdfium::span<const CJX_MethodSpec> methods);
   void MoveBufferMapData(CXFA_Object* pSrcModule, CXFA_Object* pDstModule);
   void SetMapModuleString(void* pKey, const WideStringView& wsValue);
-  void ThrowException(const wchar_t* str, ...) const;
+  void ThrowException(const WideString& str) const;
 
  private:
   void Script_Boolean_DefaultValue(CFXJSE_Value* pValue,