On Thu, Sep 12, 2013 at 08:39:11AM +0200, Jacob Carlborg wrote: > On 2013-09-12 00:50, H. S. Teoh wrote: > > >But this is JS we're talking about. What happens, boys and gals, when > >the JS interpreter encounters an uncaught error? That's right, it > >logs an error message to the error console (which is hidden by > >default in most browsers), and silently fails without any warning, > >and then the rest of the site's scripts (hooked to various event > >handlers) CONTINUE RUNNING AS IF NOTHING HAPPENED. > > My experience is that if a JavaScript fails, somehow, JavaScript fill > stop working all together on the site. But that's perhaps not the case > if an exception is thrown. But rather if you're trying to use a > variable or similar that doesn't exist. [...]
Well, you may be right, but at the time I was working on a YUI-based framework, and I discovered that either YUI, or the way the framework initializes YUI (I didn't write the base framework code so I don't know for sure), has some kind of default exception-catching code that catches such exceptions and then proceeds to *ignore* it. It does terminate the current execution thread, mind you, but all the other event handlers and hooks are still active, and the rest of the code attached to them will continue running despite the fact that something has catastrophically failed. Which, of course, means that now some object(s) are in an invalid state due to the previous failure, but the code is completely unaware of this situation and continue barging ahead and doing stuff, until it encounters the bad objects, and then random failures happen (which all get swallowed by the default catcher, thus promulgating the problem). But either way, the behaviour is equally bad. If JS stops executing upon encountering an exception, then you just randomly get a blank page (when the bug is triggered) with no helpful indication whatsoever what went wrong. If it continues executing, then you get random failures for no apparent reason. Both are equally hard to debug, and both could've been avoided had JS had *sane* handling of errors in the first place. T -- Gone Chopin. Bach in a minuet.