Bug 1195977, part 3 - Add helper for getting the number of error arguments. r=peterv
authorAndrew McCreight <continuation@gmail.com>
Tue, 15 Sep 2015 11:47:04 -0700
changeset 295263 bd02797d06af45904f44b2dd71096915c3cb78eb
parent 295262 505d11fcad960850bd7c975a841bf827e6c775f3
child 295264 f3075fbc955dcb3606b005875f45293a661220b2
push id5245
push userraliiev@mozilla.com
push dateThu, 29 Oct 2015 11:30:51 +0000
treeherdermozilla-beta@dac831dc1bd0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspeterv
bugs1195977
milestone43.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1195977, part 3 - Add helper for getting the number of error arguments. r=peterv
dom/bindings/BindingUtils.cpp
--- a/dom/bindings/BindingUtils.cpp
+++ b/dom/bindings/BindingUtils.cpp
@@ -68,16 +68,22 @@ JSErrorFormatString ErrorFormatString[] 
 
 const JSErrorFormatString*
 GetErrorMessage(void* aUserRef, const unsigned aErrorNumber)
 {
   MOZ_ASSERT(aErrorNumber < ArrayLength(ErrorFormatString));
   return &ErrorFormatString[aErrorNumber];
 }
 
+uint16_t
+GetErrorArgCount(const ErrNum aErrorNumber)
+{
+  return GetErrorMessage(nullptr, aErrorNumber)->argCount;
+}
+
 bool
 ThrowErrorMessage(JSContext* aCx, const ErrNum aErrorNumber, ...)
 {
   va_list ap;
   va_start(ap, aErrorNumber);
   JS_ReportErrorNumberVA(aCx, GetErrorMessage, nullptr,
                          static_cast<const unsigned>(aErrorNumber), ap);
   va_end(ap);
@@ -166,17 +172,17 @@ ErrorResult::ThrowErrorWithMessage(va_li
     return;
   }
   if (IsErrorWithMessage()) {
     delete mMessage;
   }
   mResult = errorType;
   Message* message = new Message();
   message->mErrorNumber = errorNumber;
-  uint16_t argCount = dom::GetErrorMessage(nullptr, errorNumber)->argCount;
+  uint16_t argCount = dom::GetErrorArgCount(errorNumber);
   while (argCount--) {
     message->mArgs.AppendElement(*va_arg(ap, const nsAString*));
   }
   mMessage = message;
 #ifdef DEBUG
   mHasMessage = true;
 #endif
 }