servo / rust-mozjs

DEPRECATED - moved to servo/mozjs instead.
Mozilla Public License 2.0
293 stars 117 forks source link

Errors are not being reported #164

Closed zofrex closed 7 years ago

zofrex commented 9 years ago

Out of the box, the registered error reporting function is not being called for me. I've narrowed it down to these two lines in Runtime::new():

            (*contextopts).set_dontReportUncaught_(true);
            (*contextopts).set_autoJSAPIOwnsErrorReporting_(true);

Unless both of these options are set to false, the error reporting function doesn't get called on error.

Ms2ger commented 9 years ago

autoJSAPIOwnsErrorReporting should definitely be true for Servo. Paging @bholley.

bholley commented 9 years ago

Yes. If you want to avoid an error reporting nightmare, Servo should do the following: 1: Set autoJSAPIOwnsErrorReporting and dontReportUncaught everywhere (hopefully on the single JSContext that Servo presumably has). 2: Register a "WarningOnlyErrorReporter", that behaves similarly to the one set by AutoJSAPI::TakeOwnershipOfErrorReporting. 3: Implementing an RAII class like AutoJSAPI, which handles errors when it gets popped off the stack.

KishanV commented 7 years ago

How can I enable error reporting on current rust-mozjs version....

Ms2ger commented 7 years ago

SpiderMonkey no longer calls a callback to report errors, just warnings (SetWarningReporter). You'll need to handle errors yourself when appropriate; there's some code in Servo you might be able to reuse.