A way of explicitly reporting exceptions
Andrea Giammarchi
andrea.giammarchi at gmail.com
Mon Jun 23 13:56:31 PDT 2014
As I've said, I haven't seen anyone mentioning the handleEvent approach
that's able to give you any info and error and stack you want whenever you
want it inside any of its listeners
```javascript
// recycle one handler
// to handle errors too
var handler = {
handleEvent: function (e) {
this[e.type](e);
},
click: function (e) {
console.log('before');
WHATEVER++
},
error: function (e) {
this._errors.push(e);
console.log(e.message);
},
_errors: []
};
document.documentElement.addEventListener(
'click', handler
);
document.documentElement.addEventListener(
'click', function () {
console.log('after');
}
);
window.addEventListener('error', handler);
```
now click the page and see how it works.
You, owning such object, can check it anywhere you want through `this` or
direct reference and verify `._errors.length` and behave accordingly.
On Mon, Jun 23, 2014 at 1:50 PM, Boris Zbarsky <bzbarsky at mit.edu> wrote:
> On 6/23/14, 4:47 PM, Andrea Giammarchi wrote:
>
>> I am saying that if your requestAnimationFrame throws mine should keep
>> working without problems
>>
>
> OK. That's the current behavior, and no one is proposing changing that.
>
> The discussion is about allowing that while usefully reporting the thrown
> exception at the same time.
>
> -Boris
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20140623/c7a7d6b9/attachment-0001.html>
More information about the es-discuss
mailing list