It doesn't seem to be able to distinguish between script errors and other errors. If you just want to catch your own exception types, then you can define your own exception constructor and deduce all your exceptions from it. Then check window.onerror to see if the object is retrieved from your custom constructor (and return true, if so, to fix the error or otherwise return false).
I think the most reliable way to do this would be to surround each asynchronous function in try / catch (although you say you don't want to do this). You can just make it an idiom; surround each asynchronous function in try / catch and call the catch lock with a function that handles the error accordingly. Or better yet, make an idiom in which the async function performs an additional βcallbackβ to the failure that it causes if an error occurs. Thus, the async caller can specify an asynchronous error handler. (This approach is used by the GWT framework, on the one hand.)
source share