summaryrefslogtreecommitdiff
path: root/xfa/fxfa/fm2js
diff options
context:
space:
mode:
Diffstat (limited to 'xfa/fxfa/fm2js')
-rw-r--r--xfa/fxfa/fm2js/xfa_fm2jscontext.cpp340
-rw-r--r--xfa/fxfa/fm2js/xfa_fm2jscontext.h11
2 files changed, 172 insertions, 179 deletions
diff --git a/xfa/fxfa/fm2js/xfa_fm2jscontext.cpp b/xfa/fxfa/fm2js/xfa_fm2jscontext.cpp
index 862571e0af..7661679b41 100644
--- a/xfa/fxfa/fm2js/xfa_fm2jscontext.cpp
+++ b/xfa/fxfa/fm2js/xfa_fm2jscontext.cpp
@@ -513,8 +513,7 @@ void CXFA_FM2JSContext::Abs(CFXJSE_Value* pThis,
const CFX_ByteStringC& szFuncName,
CFXJSE_Arguments& args) {
if (args.GetLength() != 1) {
- ToJSContext(pThis, nullptr)
- ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Abs");
+ ToJSContext(pThis, nullptr)->ThrowParamCountMismatchException(L"Abs");
return;
}
@@ -605,8 +604,7 @@ void CXFA_FM2JSContext::Ceil(CFXJSE_Value* pThis,
const CFX_ByteStringC& szFuncName,
CFXJSE_Arguments& args) {
if (args.GetLength() != 1) {
- ToJSContext(pThis, nullptr)
- ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Ceil");
+ ToJSContext(pThis, nullptr)->ThrowParamCountMismatchException(L"Ceil");
return;
}
@@ -638,7 +636,7 @@ void CXFA_FM2JSContext::Count(CFXJSE_Value* pThis,
int32_t iLength = lengthValue->ToInteger();
if (iLength <= 2) {
- pContext->ThrowException(XFA_IDS_ARGUMENT_MISMATCH);
+ pContext->ThrowArgumentMismatchException();
return;
}
@@ -681,8 +679,7 @@ void CXFA_FM2JSContext::Floor(CFXJSE_Value* pThis,
const CFX_ByteStringC& szFuncName,
CFXJSE_Arguments& args) {
if (args.GetLength() != 1) {
- ToJSContext(pThis, nullptr)
- ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Floor");
+ ToJSContext(pThis, nullptr)->ThrowParamCountMismatchException(L"Floor");
return;
}
@@ -714,7 +711,7 @@ void CXFA_FM2JSContext::Max(CFXJSE_Value* pThis,
argValue->GetObjectProperty("length", lengthValue.get());
int32_t iLength = lengthValue->ToInteger();
if (iLength <= 2) {
- pContext->ThrowException(XFA_IDS_ARGUMENT_MISMATCH);
+ pContext->ThrowArgumentMismatchException();
return;
}
@@ -790,7 +787,7 @@ void CXFA_FM2JSContext::Min(CFXJSE_Value* pThis,
argValue->GetObjectProperty("length", lengthValue.get());
int32_t iLength = lengthValue->ToInteger();
if (iLength <= 2) {
- pContext->ThrowException(XFA_IDS_ARGUMENT_MISMATCH);
+ pContext->ThrowArgumentMismatchException();
return;
}
@@ -854,7 +851,7 @@ void CXFA_FM2JSContext::Mod(CFXJSE_Value* pThis,
CFXJSE_Arguments& args) {
CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr);
if (args.GetLength() != 2) {
- pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Mod");
+ pContext->ThrowParamCountMismatchException(L"Mod");
return;
}
@@ -870,12 +867,12 @@ void CXFA_FM2JSContext::Mod(CFXJSE_Value* pThis,
bool argTwoResult;
FX_DOUBLE dDivisor = ExtractDouble(pThis, argTwo.get(), &argTwoResult);
if (!argOneResult || !argTwoResult) {
- pContext->ThrowException(XFA_IDS_ARGUMENT_MISMATCH);
+ pContext->ThrowArgumentMismatchException();
return;
}
if (dDivisor == 0.0) {
- pContext->ThrowException(XFA_IDS_DIVIDE_ZERO);
+ pContext->ThrowDivideByZeroException();
return;
}
@@ -890,7 +887,7 @@ void CXFA_FM2JSContext::Round(CFXJSE_Value* pThis,
CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr);
int32_t argc = args.GetLength();
if (argc < 1 || argc > 2) {
- pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Round");
+ pContext->ThrowParamCountMismatchException(L"Round");
return;
}
@@ -903,7 +900,7 @@ void CXFA_FM2JSContext::Round(CFXJSE_Value* pThis,
bool dValueRet;
FX_DOUBLE dValue = ExtractDouble(pThis, argOne.get(), &dValueRet);
if (!dValueRet) {
- pContext->ThrowException(XFA_IDS_ARGUMENT_MISMATCH);
+ pContext->ThrowArgumentMismatchException();
return;
}
@@ -918,7 +915,7 @@ void CXFA_FM2JSContext::Round(CFXJSE_Value* pThis,
bool dPrecisionRet;
FX_DOUBLE dPrecision = ExtractDouble(pThis, argTwo.get(), &dPrecisionRet);
if (!dPrecisionRet) {
- pContext->ThrowException(XFA_IDS_ARGUMENT_MISMATCH);
+ pContext->ThrowArgumentMismatchException();
return;
}
@@ -955,7 +952,7 @@ void CXFA_FM2JSContext::Sum(CFXJSE_Value* pThis,
argValue->GetObjectProperty("length", lengthValue.get());
int32_t iLength = lengthValue->ToInteger();
if (iLength <= 2) {
- pContext->ThrowException(XFA_IDS_ARGUMENT_MISMATCH);
+ pContext->ThrowArgumentMismatchException();
return;
}
@@ -1013,8 +1010,7 @@ void CXFA_FM2JSContext::Date(CFXJSE_Value* pThis,
const CFX_ByteStringC& szFuncName,
CFXJSE_Arguments& args) {
if (args.GetLength() != 0) {
- ToJSContext(pThis, nullptr)
- ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Date");
+ ToJSContext(pThis, nullptr)->ThrowParamCountMismatchException(L"Date");
return;
}
@@ -1039,8 +1035,7 @@ void CXFA_FM2JSContext::Date2Num(CFXJSE_Value* pThis,
CFXJSE_Arguments& args) {
int32_t argc = args.GetLength();
if (argc < 1 || argc > 3) {
- ToJSContext(pThis, nullptr)
- ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Date2Num");
+ ToJSContext(pThis, nullptr)->ThrowParamCountMismatchException(L"Date2Num");
return;
}
@@ -1090,8 +1085,7 @@ void CXFA_FM2JSContext::DateFmt(CFXJSE_Value* pThis,
CFXJSE_Arguments& args) {
int32_t argc = args.GetLength();
if (argc > 2) {
- ToJSContext(pThis, nullptr)
- ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Date2Num");
+ ToJSContext(pThis, nullptr)->ThrowParamCountMismatchException(L"Date2Num");
return;
}
@@ -1129,7 +1123,7 @@ void CXFA_FM2JSContext::IsoDate2Num(CFXJSE_Value* pThis,
CFXJSE_Arguments& args) {
if (args.GetLength() != 1) {
ToJSContext(pThis, nullptr)
- ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"IsoDate2Num");
+ ->ThrowParamCountMismatchException(L"IsoDate2Num");
return;
}
@@ -1150,8 +1144,7 @@ void CXFA_FM2JSContext::IsoTime2Num(CFXJSE_Value* pThis,
CFXJSE_Arguments& args) {
CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr);
if (args.GetLength() != 1) {
- pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD,
- L"IsoTime2Num");
+ pContext->ThrowParamCountMismatchException(L"IsoTime2Num");
return;
}
@@ -1210,7 +1203,7 @@ void CXFA_FM2JSContext::LocalDateFmt(CFXJSE_Value* pThis,
int32_t argc = args.GetLength();
if (argc > 2) {
ToJSContext(pThis, nullptr)
- ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"LocalDateFmt");
+ ->ThrowParamCountMismatchException(L"LocalDateFmt");
return;
}
@@ -1248,7 +1241,7 @@ void CXFA_FM2JSContext::LocalTimeFmt(CFXJSE_Value* pThis,
int32_t argc = args.GetLength();
if (argc > 2) {
ToJSContext(pThis, nullptr)
- ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"LocalTimeFmt");
+ ->ThrowParamCountMismatchException(L"LocalTimeFmt");
return;
}
@@ -1285,8 +1278,7 @@ void CXFA_FM2JSContext::Num2Date(CFXJSE_Value* pThis,
CFXJSE_Arguments& args) {
int32_t argc = args.GetLength();
if (argc < 1 || argc > 3) {
- ToJSContext(pThis, nullptr)
- ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Num2Date");
+ ToJSContext(pThis, nullptr)->ThrowParamCountMismatchException(L"Num2Date");
return;
}
@@ -1428,7 +1420,7 @@ void CXFA_FM2JSContext::Num2GMTime(CFXJSE_Value* pThis,
int32_t argc = args.GetLength();
if (argc < 1 || argc > 3) {
ToJSContext(pThis, nullptr)
- ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Num2GMTime");
+ ->ThrowParamCountMismatchException(L"Num2GMTime");
return;
}
@@ -1475,8 +1467,7 @@ void CXFA_FM2JSContext::Num2Time(CFXJSE_Value* pThis,
CFXJSE_Arguments& args) {
int32_t argc = args.GetLength();
if (argc < 1 || argc > 3) {
- ToJSContext(pThis, nullptr)
- ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Num2Time");
+ ToJSContext(pThis, nullptr)->ThrowParamCountMismatchException(L"Num2Time");
return;
}
@@ -1522,8 +1513,7 @@ void CXFA_FM2JSContext::Time(CFXJSE_Value* pThis,
const CFX_ByteStringC& szFuncName,
CFXJSE_Arguments& args) {
if (args.GetLength() != 0) {
- ToJSContext(pThis, nullptr)
- ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Time");
+ ToJSContext(pThis, nullptr)->ThrowParamCountMismatchException(L"Time");
return;
}
@@ -1541,8 +1531,7 @@ void CXFA_FM2JSContext::Time2Num(CFXJSE_Value* pThis,
CFXJSE_Arguments& args) {
int32_t argc = args.GetLength();
if (argc < 1 || argc > 3) {
- ToJSContext(pThis, nullptr)
- ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Time2Num");
+ ToJSContext(pThis, nullptr)->ThrowParamCountMismatchException(L"Time2Num");
return;
}
@@ -1632,8 +1621,7 @@ void CXFA_FM2JSContext::TimeFmt(CFXJSE_Value* pThis,
CFXJSE_Arguments& args) {
int32_t argc = args.GetLength();
if (argc > 2) {
- ToJSContext(pThis, nullptr)
- ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"TimeFmt");
+ ToJSContext(pThis, nullptr)->ThrowParamCountMismatchException(L"TimeFmt");
return;
}
@@ -2364,7 +2352,7 @@ void CXFA_FM2JSContext::Apr(CFXJSE_Value* pThis,
CFXJSE_Arguments& args) {
CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr);
if (args.GetLength() != 3) {
- pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Apr");
+ pContext->ThrowParamCountMismatchException(L"Apr");
return;
}
@@ -2381,7 +2369,7 @@ void CXFA_FM2JSContext::Apr(CFXJSE_Value* pThis,
FX_DOUBLE nPayment = ValueToDouble(pThis, argTwo.get());
FX_DOUBLE nPeriods = ValueToDouble(pThis, argThree.get());
if (nPrincipal <= 0 || nPayment <= 0 || nPeriods <= 0) {
- pContext->ThrowException(XFA_IDS_ARGUMENT_MISMATCH);
+ pContext->ThrowArgumentMismatchException();
return;
}
@@ -2418,7 +2406,7 @@ void CXFA_FM2JSContext::CTerm(CFXJSE_Value* pThis,
CFXJSE_Arguments& args) {
CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr);
if (args.GetLength() != 3) {
- pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"CTerm");
+ pContext->ThrowParamCountMismatchException(L"CTerm");
return;
}
@@ -2435,7 +2423,7 @@ void CXFA_FM2JSContext::CTerm(CFXJSE_Value* pThis,
FX_FLOAT nFutureValue = ValueToFloat(pThis, argTwo.get());
FX_FLOAT nInitAmount = ValueToFloat(pThis, argThree.get());
if ((nRate <= 0) || (nFutureValue <= 0) || (nInitAmount <= 0)) {
- pContext->ThrowException(XFA_IDS_ARGUMENT_MISMATCH);
+ pContext->ThrowArgumentMismatchException();
return;
}
@@ -2450,7 +2438,7 @@ void CXFA_FM2JSContext::FV(CFXJSE_Value* pThis,
CFXJSE_Arguments& args) {
CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr);
if (args.GetLength() != 3) {
- pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"FV");
+ pContext->ThrowParamCountMismatchException(L"FV");
return;
}
@@ -2467,7 +2455,7 @@ void CXFA_FM2JSContext::FV(CFXJSE_Value* pThis,
FX_DOUBLE nRate = ValueToDouble(pThis, argTwo.get());
FX_DOUBLE nPeriod = ValueToDouble(pThis, argThree.get());
if ((nRate < 0) || (nPeriod <= 0) || (nAmount <= 0)) {
- pContext->ThrowException(XFA_IDS_ARGUMENT_MISMATCH);
+ pContext->ThrowArgumentMismatchException();
return;
}
@@ -2491,7 +2479,7 @@ void CXFA_FM2JSContext::IPmt(CFXJSE_Value* pThis,
CFXJSE_Arguments& args) {
CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr);
if (args.GetLength() != 5) {
- pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"IPmt");
+ pContext->ThrowParamCountMismatchException(L"IPmt");
return;
}
@@ -2514,7 +2502,7 @@ void CXFA_FM2JSContext::IPmt(CFXJSE_Value* pThis,
FX_FLOAT nNumberOfMonths = ValueToFloat(pThis, argFive.get());
if ((nPrincipalAmount <= 0) || (nRate <= 0) || (nPayment <= 0) ||
(nFirstMonth < 0) || (nNumberOfMonths < 0)) {
- pContext->ThrowException(XFA_IDS_ARGUMENT_MISMATCH);
+ pContext->ThrowArgumentMismatchException();
return;
}
@@ -2549,7 +2537,7 @@ void CXFA_FM2JSContext::NPV(CFXJSE_Value* pThis,
CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr);
int32_t argc = args.GetLength();
if (argc < 3) {
- pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"NPV");
+ pContext->ThrowParamCountMismatchException(L"NPV");
return;
}
@@ -2564,7 +2552,7 @@ void CXFA_FM2JSContext::NPV(CFXJSE_Value* pThis,
FX_DOUBLE nRate = ValueToDouble(pThis, argValues[0].get());
if (nRate <= 0) {
- pContext->ThrowException(XFA_IDS_ARGUMENT_MISMATCH);
+ pContext->ThrowArgumentMismatchException();
return;
}
@@ -2591,7 +2579,7 @@ void CXFA_FM2JSContext::Pmt(CFXJSE_Value* pThis,
CFXJSE_Arguments& args) {
CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr);
if (args.GetLength() != 3) {
- pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Pmt");
+ pContext->ThrowParamCountMismatchException(L"Pmt");
return;
}
@@ -2608,7 +2596,7 @@ void CXFA_FM2JSContext::Pmt(CFXJSE_Value* pThis,
FX_FLOAT nRate = ValueToFloat(pThis, argTwo.get());
FX_FLOAT nPeriods = ValueToFloat(pThis, argThree.get());
if ((nPrincipal <= 0) || (nRate <= 0) || (nPeriods <= 0)) {
- pContext->ThrowException(XFA_IDS_ARGUMENT_MISMATCH);
+ pContext->ThrowArgumentMismatchException();
return;
}
@@ -2626,7 +2614,7 @@ void CXFA_FM2JSContext::PPmt(CFXJSE_Value* pThis,
CFXJSE_Arguments& args) {
CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr);
if (args.GetLength() != 5) {
- pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"PPmt");
+ pContext->ThrowParamCountMismatchException(L"PPmt");
return;
}
@@ -2649,7 +2637,7 @@ void CXFA_FM2JSContext::PPmt(CFXJSE_Value* pThis,
FX_FLOAT nNumberOfMonths = ValueToFloat(pThis, argFive.get());
if ((nPrincipalAmount <= 0) || (nRate <= 0) || (nPayment <= 0) ||
(nFirstMonth < 0) || (nNumberOfMonths < 0)) {
- pContext->ThrowException(XFA_IDS_ARGUMENT_MISMATCH);
+ pContext->ThrowArgumentMismatchException();
return;
}
@@ -2660,7 +2648,7 @@ void CXFA_FM2JSContext::PPmt(CFXJSE_Value* pThis,
FXSYS_log10((FX_FLOAT)(1 + nRateOfMonth)));
int32_t iEnd = std::min((int32_t)(nFirstMonth + nNumberOfMonths - 1), iNums);
if (nPayment < nPrincipalAmount * nRateOfMonth) {
- pContext->ThrowException(XFA_IDS_ARGUMENT_MISMATCH);
+ pContext->ThrowArgumentMismatchException();
return;
}
@@ -2684,7 +2672,7 @@ void CXFA_FM2JSContext::PV(CFXJSE_Value* pThis,
CFXJSE_Arguments& args) {
CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr);
if (args.GetLength() != 3) {
- pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"PV");
+ pContext->ThrowParamCountMismatchException(L"PV");
return;
}
@@ -2701,7 +2689,7 @@ void CXFA_FM2JSContext::PV(CFXJSE_Value* pThis,
FX_DOUBLE nRate = ValueToDouble(pThis, argTwo.get());
FX_DOUBLE nPeriod = ValueToDouble(pThis, argThree.get());
if ((nAmount <= 0) || (nRate < 0) || (nPeriod <= 0)) {
- pContext->ThrowException(XFA_IDS_ARGUMENT_MISMATCH);
+ pContext->ThrowArgumentMismatchException();
return;
}
@@ -2719,7 +2707,7 @@ void CXFA_FM2JSContext::Rate(CFXJSE_Value* pThis,
CFXJSE_Arguments& args) {
CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr);
if (args.GetLength() != 3) {
- pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Rate");
+ pContext->ThrowParamCountMismatchException(L"Rate");
return;
}
@@ -2736,7 +2724,7 @@ void CXFA_FM2JSContext::Rate(CFXJSE_Value* pThis,
FX_FLOAT nPresent = ValueToFloat(pThis, argTwo.get());
FX_FLOAT nTotalNumber = ValueToFloat(pThis, argThree.get());
if ((nFuture <= 0) || (nPresent < 0) || (nTotalNumber <= 0)) {
- pContext->ThrowException(XFA_IDS_ARGUMENT_MISMATCH);
+ pContext->ThrowArgumentMismatchException();
return;
}
@@ -2751,7 +2739,7 @@ void CXFA_FM2JSContext::Term(CFXJSE_Value* pThis,
CFXJSE_Arguments& args) {
CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr);
if (args.GetLength() != 3) {
- pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Term");
+ pContext->ThrowParamCountMismatchException(L"Term");
return;
}
@@ -2768,7 +2756,7 @@ void CXFA_FM2JSContext::Term(CFXJSE_Value* pThis,
FX_FLOAT nRate = ValueToFloat(pThis, argTwo.get());
FX_FLOAT nFuture = ValueToFloat(pThis, argThree.get());
if ((nMount <= 0) || (nRate <= 0) || (nFuture <= 0)) {
- pContext->ThrowException(XFA_IDS_ARGUMENT_MISMATCH);
+ pContext->ThrowArgumentMismatchException();
return;
}
@@ -2784,7 +2772,7 @@ void CXFA_FM2JSContext::Choose(CFXJSE_Value* pThis,
CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr);
int32_t argc = args.GetLength();
if (argc < 2) {
- pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Choose");
+ pContext->ThrowParamCountMismatchException(L"Choose");
return;
}
@@ -2854,8 +2842,7 @@ void CXFA_FM2JSContext::Exists(CFXJSE_Value* pThis,
const CFX_ByteStringC& szFuncName,
CFXJSE_Arguments& args) {
if (args.GetLength() != 1) {
- ToJSContext(pThis, nullptr)
- ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Exists");
+ ToJSContext(pThis, nullptr)->ThrowParamCountMismatchException(L"Exists");
return;
}
args.GetReturnValue()->SetInteger(args.GetValue(0)->IsObject());
@@ -2866,8 +2853,7 @@ void CXFA_FM2JSContext::HasValue(CFXJSE_Value* pThis,
const CFX_ByteStringC& szFuncName,
CFXJSE_Arguments& args) {
if (args.GetLength() != 1) {
- ToJSContext(pThis, nullptr)
- ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"HasValue");
+ ToJSContext(pThis, nullptr)->ThrowParamCountMismatchException(L"HasValue");
return;
}
@@ -2888,8 +2874,7 @@ void CXFA_FM2JSContext::Oneof(CFXJSE_Value* pThis,
const CFX_ByteStringC& szFuncName,
CFXJSE_Arguments& args) {
if (args.GetLength() < 2) {
- ToJSContext(pThis, nullptr)
- ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Oneof");
+ ToJSContext(pThis, nullptr)->ThrowParamCountMismatchException(L"Oneof");
return;
}
@@ -2916,8 +2901,7 @@ void CXFA_FM2JSContext::Within(CFXJSE_Value* pThis,
const CFX_ByteStringC& szFuncName,
CFXJSE_Arguments& args) {
if (args.GetLength() != 3) {
- ToJSContext(pThis, nullptr)
- ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Within");
+ ToJSContext(pThis, nullptr)->ThrowParamCountMismatchException(L"Within");
return;
}
@@ -2954,8 +2938,7 @@ void CXFA_FM2JSContext::If(CFXJSE_Value* pThis,
const CFX_ByteStringC& szFuncName,
CFXJSE_Arguments& args) {
if (args.GetLength() != 3) {
- ToJSContext(pThis, nullptr)
- ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"If");
+ ToJSContext(pThis, nullptr)->ThrowParamCountMismatchException(L"If");
return;
}
@@ -2970,7 +2953,7 @@ void CXFA_FM2JSContext::Eval(CFXJSE_Value* pThis,
CFXJSE_Arguments& args) {
CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr);
if (args.GetLength() != 1) {
- pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Eval");
+ pContext->ThrowParamCountMismatchException(L"Eval");
return;
}
@@ -3007,14 +2990,14 @@ void CXFA_FM2JSContext::Ref(CFXJSE_Value* pThis,
CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr);
v8::Isolate* pIsolate = pContext->GetScriptRuntime();
if (args.GetLength() != 1) {
- pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Ref");
+ pContext->ThrowParamCountMismatchException(L"Ref");
return;
}
std::unique_ptr<CFXJSE_Value> argOne = args.GetValue(0);
if (!argOne->IsArray() && !argOne->IsObject() && !argOne->IsBoolean() &&
!argOne->IsString() && !argOne->IsNull() && !argOne->IsNumber()) {
- pContext->ThrowException(XFA_IDS_ARGUMENT_MISMATCH);
+ pContext->ThrowArgumentMismatchException();
return;
}
@@ -3047,7 +3030,7 @@ void CXFA_FM2JSContext::Ref(CFXJSE_Value* pThis,
for (int32_t i = 0; i < 3; i++)
delete rgValues[i];
- pContext->ThrowException(XFA_IDS_ARGUMENT_MISMATCH);
+ pContext->ThrowArgumentMismatchException();
return;
}
@@ -3069,8 +3052,7 @@ void CXFA_FM2JSContext::UnitType(CFXJSE_Value* pThis,
const CFX_ByteStringC& szFuncName,
CFXJSE_Arguments& args) {
if (args.GetLength() != 1) {
- ToJSContext(pThis, nullptr)
- ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"UnitType");
+ ToJSContext(pThis, nullptr)->ThrowParamCountMismatchException(L"UnitType");
return;
}
@@ -3183,8 +3165,7 @@ void CXFA_FM2JSContext::UnitValue(CFXJSE_Value* pThis,
CFXJSE_Arguments& args) {
int32_t argc = args.GetLength();
if (argc < 1 || argc > 2) {
- ToJSContext(pThis, nullptr)
- ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"UnitValue");
+ ToJSContext(pThis, nullptr)->ThrowParamCountMismatchException(L"UnitValue");
return;
}
@@ -3327,8 +3308,7 @@ void CXFA_FM2JSContext::At(CFXJSE_Value* pThis,
const CFX_ByteStringC& szFuncName,
CFXJSE_Arguments& args) {
if (args.GetLength() != 2) {
- ToJSContext(pThis, nullptr)
- ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"At");
+ ToJSContext(pThis, nullptr)->ThrowParamCountMismatchException(L"At");
return;
}
@@ -3358,8 +3338,7 @@ void CXFA_FM2JSContext::Concat(CFXJSE_Value* pThis,
CFXJSE_Arguments& args) {
int32_t argc = args.GetLength();
if (argc < 1) {
- ToJSContext(pThis, nullptr)
- ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Concat");
+ ToJSContext(pThis, nullptr)->ThrowParamCountMismatchException(L"Concat");
return;
}
@@ -3391,8 +3370,7 @@ void CXFA_FM2JSContext::Decode(CFXJSE_Value* pThis,
CFXJSE_Arguments& args) {
int32_t argc = args.GetLength();
if (argc < 1 || argc > 2) {
- ToJSContext(pThis, nullptr)
- ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Decode");
+ ToJSContext(pThis, nullptr)->ThrowParamCountMismatchException(L"Decode");
return;
}
@@ -3666,8 +3644,7 @@ void CXFA_FM2JSContext::Encode(CFXJSE_Value* pThis,
CFXJSE_Arguments& args) {
int32_t argc = args.GetLength();
if (argc < 1 || argc > 2) {
- ToJSContext(pThis, nullptr)
- ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Encode");
+ ToJSContext(pThis, nullptr)->ThrowParamCountMismatchException(L"Encode");
return;
}
@@ -3985,7 +3962,7 @@ void CXFA_FM2JSContext::Format(CFXJSE_Value* pThis,
CFXJSE_Arguments& args) {
CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr);
if (args.GetLength() < 2) {
- pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Format");
+ pContext->ThrowParamCountMismatchException(L"Format");
return;
}
@@ -4063,8 +4040,7 @@ void CXFA_FM2JSContext::Left(CFXJSE_Value* pThis,
const CFX_ByteStringC& szFuncName,
CFXJSE_Arguments& args) {
if (args.GetLength() != 2) {
- ToJSContext(pThis, nullptr)
- ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Left");
+ ToJSContext(pThis, nullptr)->ThrowParamCountMismatchException(L"Left");
return;
}
@@ -4087,8 +4063,7 @@ void CXFA_FM2JSContext::Len(CFXJSE_Value* pThis,
const CFX_ByteStringC& szFuncName,
CFXJSE_Arguments& args) {
if (args.GetLength() != 1) {
- ToJSContext(pThis, nullptr)
- ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Len");
+ ToJSContext(pThis, nullptr)->ThrowParamCountMismatchException(L"Len");
return;
}
@@ -4109,8 +4084,7 @@ void CXFA_FM2JSContext::Lower(CFXJSE_Value* pThis,
CFXJSE_Arguments& args) {
int32_t argc = args.GetLength();
if (argc < 1 || argc > 2) {
- ToJSContext(pThis, nullptr)
- ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Lower");
+ ToJSContext(pThis, nullptr)->ThrowParamCountMismatchException(L"Lower");
return;
}
@@ -4148,8 +4122,7 @@ void CXFA_FM2JSContext::Ltrim(CFXJSE_Value* pThis,
const CFX_ByteStringC& szFuncName,
CFXJSE_Arguments& args) {
if (args.GetLength() != 1) {
- ToJSContext(pThis, nullptr)
- ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Ltrim");
+ ToJSContext(pThis, nullptr)->ThrowParamCountMismatchException(L"Ltrim");
return;
}
@@ -4171,7 +4144,7 @@ void CXFA_FM2JSContext::Parse(CFXJSE_Value* pThis,
CFXJSE_Arguments& args) {
CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr);
if (args.GetLength() != 2) {
- pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Parse");
+ pContext->ThrowParamCountMismatchException(L"Parse");
return;
}
@@ -4302,8 +4275,7 @@ void CXFA_FM2JSContext::Replace(CFXJSE_Value* pThis,
CFXJSE_Arguments& args) {
int32_t argc = args.GetLength();
if (argc < 2 || argc > 3) {
- ToJSContext(pThis, nullptr)
- ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Replace");
+ ToJSContext(pThis, nullptr)->ThrowParamCountMismatchException(L"Replace");
return;
}
@@ -4361,8 +4333,7 @@ void CXFA_FM2JSContext::Right(CFXJSE_Value* pThis,
const CFX_ByteStringC& szFuncName,
CFXJSE_Arguments& args) {
if (args.GetLength() != 2) {
- ToJSContext(pThis, nullptr)
- ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Right");
+ ToJSContext(pThis, nullptr)->ThrowParamCountMismatchException(L"Right");
return;
}
@@ -4385,8 +4356,7 @@ void CXFA_FM2JSContext::Rtrim(CFXJSE_Value* pThis,
const CFX_ByteStringC& szFuncName,
CFXJSE_Arguments& args) {
if (args.GetLength() != 1) {
- ToJSContext(pThis, nullptr)
- ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Rtrim");
+ ToJSContext(pThis, nullptr)->ThrowParamCountMismatchException(L"Rtrim");
return;
}
@@ -4407,8 +4377,7 @@ void CXFA_FM2JSContext::Space(CFXJSE_Value* pThis,
const CFX_ByteStringC& szFuncName,
CFXJSE_Arguments& args) {
if (args.GetLength() != 1) {
- ToJSContext(pThis, nullptr)
- ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Space");
+ ToJSContext(pThis, nullptr)->ThrowParamCountMismatchException(L"Space");
return;
}
@@ -4435,8 +4404,7 @@ void CXFA_FM2JSContext::Str(CFXJSE_Value* pThis,
CFXJSE_Arguments& args) {
int32_t argc = args.GetLength();
if (argc < 1 || argc > 3) {
- ToJSContext(pThis, nullptr)
- ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Str");
+ ToJSContext(pThis, nullptr)->ThrowParamCountMismatchException(L"Str");
return;
}
@@ -4552,8 +4520,7 @@ void CXFA_FM2JSContext::Stuff(CFXJSE_Value* pThis,
CFXJSE_Arguments& args) {
int32_t argc = args.GetLength();
if (argc < 3 || argc > 4) {
- ToJSContext(pThis, nullptr)
- ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Stuff");
+ ToJSContext(pThis, nullptr)->ThrowParamCountMismatchException(L"Stuff");
return;
}
@@ -4602,8 +4569,7 @@ void CXFA_FM2JSContext::Substr(CFXJSE_Value* pThis,
const CFX_ByteStringC& szFuncName,
CFXJSE_Arguments& args) {
if (args.GetLength() != 3) {
- ToJSContext(pThis, nullptr)
- ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Substr");
+ ToJSContext(pThis, nullptr)->ThrowParamCountMismatchException(L"Substr");
return;
}
@@ -4643,8 +4609,7 @@ void CXFA_FM2JSContext::Uuid(CFXJSE_Value* pThis,
CFXJSE_Arguments& args) {
int32_t argc = args.GetLength();
if (argc < 0 || argc > 1) {
- ToJSContext(pThis, nullptr)
- ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Uuid");
+ ToJSContext(pThis, nullptr)->ThrowParamCountMismatchException(L"Uuid");
return;
}
@@ -4667,8 +4632,7 @@ void CXFA_FM2JSContext::Upper(CFXJSE_Value* pThis,
CFXJSE_Arguments& args) {
int32_t argc = args.GetLength();
if (argc < 1 || argc > 2) {
- ToJSContext(pThis, nullptr)
- ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Upper");
+ ToJSContext(pThis, nullptr)->ThrowParamCountMismatchException(L"Upper");
return;
}
@@ -4708,8 +4672,7 @@ void CXFA_FM2JSContext::WordNum(CFXJSE_Value* pThis,
CFXJSE_Arguments& args) {
int32_t argc = args.GetLength();
if (argc < 1 || argc > 3) {
- ToJSContext(pThis, nullptr)
- ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"WordNum");
+ ToJSContext(pThis, nullptr)->ThrowParamCountMismatchException(L"WordNum");
return;
}
@@ -4909,7 +4872,7 @@ void CXFA_FM2JSContext::Get(CFXJSE_Value* pThis,
CFXJSE_Arguments& args) {
CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr);
if (args.GetLength() != 1) {
- pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Get");
+ pContext->ThrowParamCountMismatchException(L"Get");
return;
}
@@ -4942,7 +4905,7 @@ void CXFA_FM2JSContext::Post(CFXJSE_Value* pThis,
CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr);
int32_t argc = args.GetLength();
if (argc < 2 || argc > 5) {
- pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Post");
+ pContext->ThrowParamCountMismatchException(L"Post");
return;
}
@@ -4987,7 +4950,7 @@ void CXFA_FM2JSContext::Post(CFXJSE_Value* pThis,
CFX_WideString::FromUTF8(bsContentType.AsStringC()),
CFX_WideString::FromUTF8(bsEncode.AsStringC()),
CFX_WideString::FromUTF8(bsHeader.AsStringC()), decodedResponse)) {
- pContext->ThrowException(XFA_IDS_SERVER_DENY);
+ pContext->ThrowServerDeniedException();
return;
}
@@ -5003,7 +4966,7 @@ void CXFA_FM2JSContext::Put(CFXJSE_Value* pThis,
CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr);
int32_t argc = args.GetLength();
if (argc < 2 || argc > 3) {
- pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Put");
+ pContext->ThrowParamCountMismatchException(L"Put");
return;
}
@@ -5033,7 +4996,7 @@ void CXFA_FM2JSContext::Put(CFXJSE_Value* pThis,
CFX_WideString::FromUTF8(bsURL.AsStringC()),
CFX_WideString::FromUTF8(bsData.AsStringC()),
CFX_WideString::FromUTF8(bsEncode.AsStringC()))) {
- pContext->ThrowException(XFA_IDS_SERVER_DENY);
+ pContext->ThrowServerDeniedException();
return;
}
@@ -5046,7 +5009,7 @@ void CXFA_FM2JSContext::assign_value_operator(CFXJSE_Value* pThis,
CFXJSE_Arguments& args) {
CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr);
if (args.GetLength() != 2) {
- pContext->ThrowException(XFA_IDS_COMPILER_ERROR);
+ pContext->ThrowCompilerErrorException();
return;
}
@@ -5064,7 +5027,7 @@ void CXFA_FM2JSContext::assign_value_operator(CFXJSE_Value* pThis,
for (int32_t i = 2; i < iLeftLength; i++) {
lValue->GetObjectPropertyByIdx(i, jsObjectValue.get());
if (!SetObjectDefaultValue(jsObjectValue.get(), rValue.get())) {
- pContext->ThrowException(XFA_IDS_NOT_DEFAUL_VALUE);
+ pContext->ThrowNoDefaultPropertyException(szFuncName);
return;
}
}
@@ -5077,7 +5040,7 @@ void CXFA_FM2JSContext::assign_value_operator(CFXJSE_Value* pThis,
}
} else if (lValue->IsObject()) {
if (!SetObjectDefaultValue(lValue.get(), rValue.get())) {
- pContext->ThrowException(XFA_IDS_NOT_DEFAUL_VALUE);
+ pContext->ThrowNoDefaultPropertyException(szFuncName);
return;
}
}
@@ -5089,7 +5052,7 @@ void CXFA_FM2JSContext::logical_or_operator(CFXJSE_Value* pThis,
const CFX_ByteStringC& szFuncName,
CFXJSE_Arguments& args) {
if (args.GetLength() != 2) {
- ToJSContext(pThis, nullptr)->ThrowException(XFA_IDS_COMPILER_ERROR);
+ ToJSContext(pThis, nullptr)->ThrowCompilerErrorException();
return;
}
@@ -5110,7 +5073,7 @@ void CXFA_FM2JSContext::logical_and_operator(CFXJSE_Value* pThis,
const CFX_ByteStringC& szFuncName,
CFXJSE_Arguments& args) {
if (args.GetLength() != 2) {
- ToJSContext(pThis, nullptr)->ThrowException(XFA_IDS_COMPILER_ERROR);
+ ToJSContext(pThis, nullptr)->ThrowCompilerErrorException();
return;
}
@@ -5131,7 +5094,7 @@ void CXFA_FM2JSContext::equality_operator(CFXJSE_Value* pThis,
const CFX_ByteStringC& szFuncName,
CFXJSE_Arguments& args) {
if (args.GetLength() != 2) {
- ToJSContext(pThis, nullptr)->ThrowException(XFA_IDS_COMPILER_ERROR);
+ ToJSContext(pThis, nullptr)->ThrowCompilerErrorException();
return;
}
@@ -5164,7 +5127,7 @@ void CXFA_FM2JSContext::notequality_operator(CFXJSE_Value* pThis,
const CFX_ByteStringC& szFuncName,
CFXJSE_Arguments& args) {
if (args.GetLength() != 2) {
- ToJSContext(pThis, nullptr)->ThrowException(XFA_IDS_COMPILER_ERROR);
+ ToJSContext(pThis, nullptr)->ThrowCompilerErrorException();
return;
}
@@ -5224,7 +5187,7 @@ void CXFA_FM2JSContext::less_operator(CFXJSE_Value* pThis,
const CFX_ByteStringC& szFuncName,
CFXJSE_Arguments& args) {
if (args.GetLength() != 2) {
- ToJSContext(pThis, nullptr)->ThrowException(XFA_IDS_COMPILER_ERROR);
+ ToJSContext(pThis, nullptr)->ThrowCompilerErrorException();
return;
}
@@ -5251,7 +5214,7 @@ void CXFA_FM2JSContext::lessequal_operator(CFXJSE_Value* pThis,
const CFX_ByteStringC& szFuncName,
CFXJSE_Arguments& args) {
if (args.GetLength() != 2) {
- ToJSContext(pThis, nullptr)->ThrowException(XFA_IDS_COMPILER_ERROR);
+ ToJSContext(pThis, nullptr)->ThrowCompilerErrorException();
return;
}
@@ -5279,7 +5242,7 @@ void CXFA_FM2JSContext::greater_operator(CFXJSE_Value* pThis,
const CFX_ByteStringC& szFuncName,
CFXJSE_Arguments& args) {
if (args.GetLength() != 2) {
- ToJSContext(pThis, nullptr)->ThrowException(XFA_IDS_COMPILER_ERROR);
+ ToJSContext(pThis, nullptr)->ThrowCompilerErrorException();
return;
}
@@ -5306,7 +5269,7 @@ void CXFA_FM2JSContext::greaterequal_operator(CFXJSE_Value* pThis,
const CFX_ByteStringC& szFuncName,
CFXJSE_Arguments& args) {
if (args.GetLength() != 2) {
- ToJSContext(pThis, nullptr)->ThrowException(XFA_IDS_COMPILER_ERROR);
+ ToJSContext(pThis, nullptr)->ThrowCompilerErrorException();
return;
}
@@ -5334,7 +5297,7 @@ void CXFA_FM2JSContext::plus_operator(CFXJSE_Value* pThis,
const CFX_ByteStringC& szFuncName,
CFXJSE_Arguments& args) {
if (args.GetLength() != 2) {
- ToJSContext(pThis, nullptr)->ThrowException(XFA_IDS_COMPILER_ERROR);
+ ToJSContext(pThis, nullptr)->ThrowCompilerErrorException();
return;
}
@@ -5356,7 +5319,7 @@ void CXFA_FM2JSContext::minus_operator(CFXJSE_Value* pThis,
const CFX_ByteStringC& szFuncName,
CFXJSE_Arguments& args) {
if (args.GetLength() != 2) {
- ToJSContext(pThis, nullptr)->ThrowException(XFA_IDS_COMPILER_ERROR);
+ ToJSContext(pThis, nullptr)->ThrowCompilerErrorException();
return;
}
@@ -5377,7 +5340,7 @@ void CXFA_FM2JSContext::multiple_operator(CFXJSE_Value* pThis,
const CFX_ByteStringC& szFuncName,
CFXJSE_Arguments& args) {
if (args.GetLength() != 2) {
- ToJSContext(pThis, nullptr)->ThrowException(XFA_IDS_COMPILER_ERROR);
+ ToJSContext(pThis, nullptr)->ThrowCompilerErrorException();
return;
}
@@ -5399,7 +5362,7 @@ void CXFA_FM2JSContext::divide_operator(CFXJSE_Value* pThis,
CFXJSE_Arguments& args) {
CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr);
if (args.GetLength() != 2) {
- pContext->ThrowException(XFA_IDS_COMPILER_ERROR);
+ pContext->ThrowCompilerErrorException();
return;
}
@@ -5412,7 +5375,7 @@ void CXFA_FM2JSContext::divide_operator(CFXJSE_Value* pThis,
FX_DOUBLE second = ValueToDouble(pThis, argSecond.get());
if (second == 0.0) {
- pContext->ThrowException(XFA_IDS_DIVIDE_ZERO);
+ pContext->ThrowDivideByZeroException();
return;
}
@@ -5425,7 +5388,7 @@ void CXFA_FM2JSContext::positive_operator(CFXJSE_Value* pThis,
const CFX_ByteStringC& szFuncName,
CFXJSE_Arguments& args) {
if (args.GetLength() != 1) {
- ToJSContext(pThis, nullptr)->ThrowException(XFA_IDS_COMPILER_ERROR);
+ ToJSContext(pThis, nullptr)->ThrowCompilerErrorException();
return;
}
@@ -5442,7 +5405,7 @@ void CXFA_FM2JSContext::negative_operator(CFXJSE_Value* pThis,
const CFX_ByteStringC& szFuncName,
CFXJSE_Arguments& args) {
if (args.GetLength() != 1) {
- ToJSContext(pThis, nullptr)->ThrowException(XFA_IDS_COMPILER_ERROR);
+ ToJSContext(pThis, nullptr)->ThrowCompilerErrorException();
return;
}
@@ -5459,7 +5422,7 @@ void CXFA_FM2JSContext::logical_not_operator(CFXJSE_Value* pThis,
const CFX_ByteStringC& szFuncName,
CFXJSE_Arguments& args) {
if (args.GetLength() != 1) {
- ToJSContext(pThis, nullptr)->ThrowException(XFA_IDS_COMPILER_ERROR);
+ ToJSContext(pThis, nullptr)->ThrowCompilerErrorException();
return;
}
@@ -5481,7 +5444,7 @@ void CXFA_FM2JSContext::dot_accessor(CFXJSE_Value* pThis,
v8::Isolate* pIsolate = pContext->GetScriptRuntime();
int32_t argc = args.GetLength();
if (argc < 4 || argc > 5) {
- pContext->ThrowException(XFA_IDS_COMPILER_ERROR);
+ pContext->ThrowCompilerErrorException();
return;
}
@@ -5522,12 +5485,9 @@ void CXFA_FM2JSContext::dot_accessor(CFXJSE_Value* pThis,
}
}
if (iCounter < 1) {
- CFX_WideString wsPropertyName =
- CFX_WideString::FromUTF8(szName.AsStringC());
- CFX_WideString wsSomExpression =
- CFX_WideString::FromUTF8(szSomExp.AsStringC());
- pContext->ThrowException(XFA_IDS_ACCESS_PROPERTY_IN_NOT_OBJECT,
- wsPropertyName.c_str(), wsSomExpression.c_str());
+ pContext->ThrowPropertyNotInObjectException(
+ CFX_WideString::FromUTF8(szName.AsStringC()),
+ CFX_WideString::FromUTF8(szSomExp.AsStringC()));
return;
}
@@ -5581,12 +5541,9 @@ void CXFA_FM2JSContext::dot_accessor(CFXJSE_Value* pThis,
resoveNodeRS, true, szName.IsEmpty());
}
if (iRet < 1) {
- CFX_WideString wsPropertyName =
- CFX_WideString::FromUTF8(szName.AsStringC());
- CFX_WideString wsSomExpression =
- CFX_WideString::FromUTF8(szSomExp.AsStringC());
- pContext->ThrowException(XFA_IDS_ACCESS_PROPERTY_IN_NOT_OBJECT,
- wsPropertyName.c_str(), wsSomExpression.c_str());
+ pContext->ThrowPropertyNotInObjectException(
+ CFX_WideString::FromUTF8(szName.AsStringC()),
+ CFX_WideString::FromUTF8(szSomExp.AsStringC()));
return;
}
@@ -5626,7 +5583,7 @@ void CXFA_FM2JSContext::dotdot_accessor(CFXJSE_Value* pThis,
v8::Isolate* pIsolate = pContext->GetScriptRuntime();
int32_t argc = args.GetLength();
if (argc < 4 || argc > 5) {
- pContext->ThrowException(XFA_IDS_COMPILER_ERROR);
+ pContext->ThrowCompilerErrorException();
return;
}
@@ -5664,12 +5621,9 @@ void CXFA_FM2JSContext::dotdot_accessor(CFXJSE_Value* pThis,
}
}
if (iCounter < 1) {
- CFX_WideString wsPropertyName =
- CFX_WideString::FromUTF8(szName.AsStringC());
- CFX_WideString wsSomExpression =
- CFX_WideString::FromUTF8(szSomExp.AsStringC());
- pContext->ThrowException(XFA_IDS_ACCESS_PROPERTY_IN_NOT_OBJECT,
- wsPropertyName.c_str(), wsSomExpression.c_str());
+ pContext->ThrowPropertyNotInObjectException(
+ CFX_WideString::FromUTF8(szName.AsStringC()),
+ CFX_WideString::FromUTF8(szSomExp.AsStringC()));
return;
}
@@ -5719,12 +5673,9 @@ void CXFA_FM2JSContext::dotdot_accessor(CFXJSE_Value* pThis,
resoveNodeRS, false);
}
if (iRet < 1) {
- CFX_WideString wsPropertyName =
- CFX_WideString::FromUTF8(szName.AsStringC());
- CFX_WideString wsSomExpression =
- CFX_WideString::FromUTF8(szSomExp.AsStringC());
- pContext->ThrowException(XFA_IDS_ACCESS_PROPERTY_IN_NOT_OBJECT,
- wsPropertyName.c_str(), wsSomExpression.c_str());
+ pContext->ThrowPropertyNotInObjectException(
+ CFX_WideString::FromUTF8(szName.AsStringC()),
+ CFX_WideString::FromUTF8(szSomExp.AsStringC()));
return;
}
@@ -5763,7 +5714,7 @@ void CXFA_FM2JSContext::eval_translation(CFXJSE_Value* pThis,
CFXJSE_Arguments& args) {
CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr);
if (args.GetLength() != 1) {
- pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Eval");
+ pContext->ThrowParamCountMismatchException(L"Eval");
return;
}
@@ -5771,7 +5722,7 @@ void CXFA_FM2JSContext::eval_translation(CFXJSE_Value* pThis,
CFX_ByteString argString;
ValueToUTF8String(argOne.get(), argString);
if (argString.IsEmpty()) {
- pContext->ThrowException(XFA_IDS_ARGUMENT_MISMATCH);
+ pContext->ThrowArgumentMismatchException();
return;
}
@@ -5781,7 +5732,7 @@ void CXFA_FM2JSContext::eval_translation(CFXJSE_Value* pThis,
CXFA_FM2JSContext::Translate(scriptString.AsStringC(), wsJavaScriptBuf,
wsError);
if (!wsError.IsEmpty()) {
- pContext->ThrowException(XFA_IDS_COMPILER_ERROR);
+ pContext->ThrowCompilerErrorException();
return;
}
@@ -5822,7 +5773,7 @@ void CXFA_FM2JSContext::get_fm_value(CFXJSE_Value* pThis,
CFXJSE_Arguments& args) {
CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr);
if (args.GetLength() != 1) {
- pContext->ThrowException(XFA_IDS_COMPILER_ERROR);
+ pContext->ThrowCompilerErrorException();
return;
}
@@ -5856,7 +5807,7 @@ void CXFA_FM2JSContext::get_fm_jsobj(CFXJSE_Value* pThis,
const CFX_ByteStringC& szFuncName,
CFXJSE_Arguments& args) {
if (args.GetLength() != 1) {
- ToJSContext(pThis, nullptr)->ThrowException(XFA_IDS_COMPILER_ERROR);
+ ToJSContext(pThis, nullptr)->ThrowCompilerErrorException();
return;
}
@@ -5883,7 +5834,7 @@ void CXFA_FM2JSContext::fm_var_filter(CFXJSE_Value* pThis,
CFXJSE_Arguments& args) {
CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr);
if (args.GetLength() != 1) {
- pContext->ThrowException(XFA_IDS_COMPILER_ERROR);
+ pContext->ThrowCompilerErrorException();
return;
}
@@ -5928,7 +5879,7 @@ void CXFA_FM2JSContext::fm_var_filter(CFXJSE_Value* pThis,
std::unique_ptr<CFXJSE_Value> objectValue(new CFXJSE_Value(pIsolate));
argOne->GetObjectPropertyByIdx(2, objectValue.get());
if (objectValue->IsNull()) {
- pContext->ThrowException(XFA_IDS_COMPILER_ERROR);
+ pContext->ThrowCompilerErrorException();
return;
}
args.GetReturnValue()->Assign(argOne.get());
@@ -6509,14 +6460,47 @@ void CXFA_FM2JSContext::GlobalPropertyGetter(CFXJSE_Value* pValue) {
pValue->Assign(m_pValue.get());
}
-void CXFA_FM2JSContext::ThrowException(int32_t iStringID, ...) {
- IXFA_AppProvider* pAppProvider = m_pDocument->GetNotify()->GetAppProvider();
- ASSERT(pAppProvider);
+void CXFA_FM2JSContext::ThrowNoDefaultPropertyException(
+ const CFX_ByteStringC& name) const {
+ ThrowException(L"%s doesn't have a default property.", name.c_str());
+}
+
+void CXFA_FM2JSContext::ThrowCompilerErrorException() const {
+ ThrowException(L"Compiler error.");
+}
+
+void CXFA_FM2JSContext::ThrowDivideByZeroException() const {
+ ThrowException(L"Divide by zero.");
+}
+
+void CXFA_FM2JSContext::ThrowServerDeniedException() const {
+ ThrowException(L"Server does not permit operation.");
+}
+
+void CXFA_FM2JSContext::ThrowPropertyNotInObjectException(
+ const CFX_WideString& name,
+ const CFX_WideString& exp) const {
+ ThrowException(
+ L"An attempt was made to reference property '%s' of a non-object "
+ L"in SOM expression %s.",
+ name.c_str(), exp.c_str());
+}
+
+void CXFA_FM2JSContext::ThrowParamCountMismatchException(
+ const CFX_WideString& method) const {
+ ThrowException(L"Incorrect number of parameters calling method '%s'.",
+ method.c_str());
+}
+
+void CXFA_FM2JSContext::ThrowArgumentMismatchException() const {
+ ThrowException(L"Argument mismatch in property or function argument.");
+}
+void CXFA_FM2JSContext::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());
diff --git a/xfa/fxfa/fm2js/xfa_fm2jscontext.h b/xfa/fxfa/fm2js/xfa_fm2jscontext.h
index f6be186c15..413cb3027a 100644
--- a/xfa/fxfa/fm2js/xfa_fm2jscontext.h
+++ b/xfa/fxfa/fm2js/xfa_fm2jscontext.h
@@ -452,7 +452,16 @@ class CXFA_FM2JSContext : public CFXJSE_HostObject {
private:
v8::Isolate* GetScriptRuntime() const { return m_pIsolate; }
CXFA_Document* GetDocument() const { return m_pDocument; }
- void ThrowException(int32_t iStringID, ...);
+
+ void ThrowNoDefaultPropertyException(const CFX_ByteStringC& name) const;
+ void ThrowCompilerErrorException() const;
+ void ThrowDivideByZeroException() const;
+ void ThrowServerDeniedException() const;
+ void ThrowPropertyNotInObjectException(const CFX_WideString& name,
+ const CFX_WideString& exp) const;
+ void ThrowArgumentMismatchException() const;
+ void ThrowParamCountMismatchException(const CFX_WideString& method) const;
+ void ThrowException(const FX_WCHAR* str, ...) const;
v8::Isolate* m_pIsolate;
CFXJSE_Class* m_pFMClass;