Exceptions inside AJAX handlers are sent to onException and then
swallowed.  The behavior I think most people would expect is that if
they're not using any onException handlers, exceptions should be
raised normally, not silently discarded.  That's the behavior I
want--for errors to always go to the error console, like all other
errors.  (I can see the underlying reason for this behavior--so
callbacks are guaranteed to be called, even if one of them
misbehaves.)

I can work around this with a responder:

Ajax.Responders.register({
        onException: function(request, exception) {
                (function() { throw exception; }).defer();
        }
});

The defer() is necessary to break out of Ajax.Responders.dispatch's
exception handler, which silently eats everything.  This also has the
nice property that if multiple callbacks throw errors, the callback
chain isn't broken, but all of the errors are still shown.  It's also
not dependant on responder order; if it's registered first, later
responders still run.

I'm not sure if throwing an exception outside of the context it was
originally thrown will confuse JS debuggers.  (I don't use one; they
all destabilize FF badly for me.)

It would be nice to have this behavior by default.  I suspect most
people who use Prototype AJAX have been bitten by this, and this
workaround is a bit obscure for people to have to discover on their
own.

-- 
Glenn Maynard

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to