@@ -1729,8 +1729,7 @@ def definition_body(self):
17291729 { // Scope to make sure |result| goes out of scope while |v| is rooted
17301730 RefPtr<mozilla::dom::${descriptorName}> result = ConstructNavigatorObjectHelper(aCx, global, rv);
17311731 rv.WouldReportJSException();
1732- if (rv.Failed()) {
1733- ThrowMethodFailed(aCx, rv);
1732+ if (rv.MaybeSetPendingException(aCx)) {
17341733 return nullptr;
17351734 }
17361735 if (!GetOrCreateDOMReflector(aCx, result, &v)) {
@@ -5101,8 +5100,7 @@ def handleNull(templateBody, setToNullVar, extraConditionForNull=""):
51015100 }
51025101 ErrorResult promiseRv;
51035102 $${declName} = Promise::Resolve(promiseGlobal, $${val}, promiseRv);
5104- if (promiseRv.Failed()) {
5105- ThrowMethodFailed(cx, promiseRv);
5103+ if (promiseRv.MaybeSetPendingException(cx)) {
51065104 $*{exceptionCode}
51075105 }
51085106 }
@@ -6664,23 +6662,18 @@ class CGCallGenerator(CGThing):
66646662 A class to generate an actual call to a C++ object. Assumes that the C++
66656663 object is stored in a variable whose name is given by the |object| argument.
66666664
6667- errorReport should be a CGThing for an error report or None if no
6668- error reporting is needed.
6665+ isFallible is a boolean indicating whether the call should be fallible.
66696666
66706667 resultVar: If the returnType is not void, then the result of the call is
66716668 stored in a C++ variable named by resultVar. The caller is responsible for
66726669 declaring the result variable. If the caller doesn't care about the result
66736670 value, resultVar can be omitted.
66746671 """
6675- def __init__(self, errorReport , arguments, argsPre, returnType,
6672+ def __init__(self, isFallible , arguments, argsPre, returnType,
66766673 extendedAttributes, descriptorProvider, nativeMethodName,
66776674 static, object="self", argsPost=[], resultVar=None):
66786675 CGThing.__init__(self)
66796676
6680- assert errorReport is None or isinstance(errorReport, CGThing)
6681-
6682- isFallible = errorReport is not None
6683-
66846677 result, resultOutParam, resultRooter, resultArgs, resultConversion = \
66856678 getRetvalDeclarationForType(returnType, descriptorProvider)
66866679
@@ -6775,10 +6768,13 @@ def needsConst(a):
67756768
67766769 if isFallible:
67776770 self.cgRoot.prepend(CGGeneric("ErrorResult rv;\n"))
6778- self.cgRoot.append(CGGeneric("rv.WouldReportJSException();\n"))
6779- self.cgRoot.append(CGGeneric("if (MOZ_UNLIKELY(rv.Failed())) {\n"))
6780- self.cgRoot.append(CGIndenter(errorReport))
6781- self.cgRoot.append(CGGeneric("}\n"))
6771+ self.cgRoot.append(CGGeneric(dedent(
6772+ """
6773+ rv.WouldReportJSException();
6774+ if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
6775+ return false;
6776+ }
6777+ """)))
67826778
67836779 self.cgRoot.append(CGGeneric("MOZ_ASSERT(!JS_IsExceptionPending(cx));\n"))
67846780
@@ -7172,7 +7168,7 @@ def __init__(self, returnType, arguments, nativeMethodName, static,
71727168 idlNode.identifier.name))
71737169 else:
71747170 cgThings.append(CGCallGenerator(
7175- self.getErrorReport() if self. isFallible() else None ,
7171+ self.isFallible(),
71767172 self.getArguments(), argsPre, returnType,
71777173 self.extendedAttributes, descriptor, nativeMethodName,
71787174 static, argsPost=argsPost, resultVar=resultVar))
@@ -7279,9 +7275,6 @@ def wrap_return_value(self):
72797275 maybeWrap=getMaybeWrapValueFuncForType(self.idlNode.type))
72807276 return wrapCode
72817277
7282- def getErrorReport(self):
7283- return CGGeneric('return ThrowMethodFailed(cx, rv);\n')
7284-
72857278 def define(self):
72867279 return (self.cgRoot.define() + self.wrap_return_value())
72877280
@@ -8251,8 +8244,8 @@ def generate_code(self):
82518244 ErrorResult rv;
82528245 self->GetOwnPropertyNames(cx, names, rv);
82538246 rv.WouldReportJSException();
8254- if (rv.Failed( )) {
8255- return ThrowMethodFailed(cx, rv) ;
8247+ if (rv.MaybeSetPendingException(cx )) {
8248+ return false ;
82568249 }
82578250 bool dummy;
82588251 for (uint32_t i = 0; i < names.Length(); ++i) {
@@ -10309,8 +10302,8 @@ def generate_code(self):
1030910302 ErrorResult rv;
1031010303 self->GetOwnPropertyNames(cx, names, rv);
1031110304 rv.WouldReportJSException();
10312- if (rv.Failed( )) {
10313- return ThrowMethodFailed(cx, rv) ;
10305+ if (rv.MaybeSetPendingException(cx )) {
10306+ return false ;
1031410307 }
1031510308 // OK to pass null as "proxy" because it's ignored if
1031610309 // shadowPrototypeProperties is true
0 commit comments