JS XPCOM and error reporting (Bug 1044109 )

Kent James kent at caspia.com
Fri Jul 1 03:17:54 UTC 2016

One of the most annoying is QueryInterface, which by its name is asking
if an interface exists. If it does not, it throws. I've had to add a
non-throwing GetInterface (nsIInterfaceRequestor) to get around this

The message database is also going to be a problem, as we routinely use
error returns to signify different status, like database does not exist
or is out of date and needs reloading. Those cases, when there is error
recovery built in that is expected to be used routinely, will need to be
changed so that they do not use rv values (which equate to a throw in JS
XPCOM) to communicate recoverable issues.


On 6/30/2016 6:54 PM, Ben Bucksch wrote:
> R Kent James wrote on 23.06.2016 19:48:
>> Throws in JS should be reserved for cases where they are considered
>> unexpected
> That's always been the rule for exceptions, even in C++. Hence the name.
> Stroustroup has even been fairly explicit about this.
>> I'm not really happy about this, as JS exceptions can be useful. Are
>> there reasonable alternatives here?
> Can you give some representative examples that are common where you
> have the problem often?
> Ben
> _______________________________________________
> tb-planning mailing list
> tb-planning at mozilla.org
> https://mail.mozilla.org/listinfo/tb-planning

More information about the tb-planning mailing list