On Thu, May 14, 2009 at 3:24 AM, T.J. Crowder <[email protected]> wrote:
> I don't think they would, but more to the point, "raised normally"
> *where*? In the normal case (asynchronous requests), the code that
> initiated the request has long since completed. So unless you mean
> raising exceptions to the browser (which doesn't seem like a good
> idea, and can result in your script being terminated completely), I
> don't see where it would get raised. And there's no standard for a
> global exception catcher, is there? Some browsers have them, I think,
> but I don't know of a standard for one. So even if Prototype raised
> the exception globally, how would you handle it?
Errors in my code, when I havn't installed any error handler
explicitly, should be returned to the browser, to be displayed in the
usual error windows. If I want some other behavior, I'll install an
error handler (whether a try/catch block or, for Ajax.Request, an
onException handler). Discarding errors by default is very strange.
The exception should minimally be re-thrown if no onException
handlers, local or global, exist. Attached patch (not heavily tested)
shows what I mean.
> to be a fairly useful paradigm. (try = request, catch = onException,
> finally = onComplete) Maybe there could be an argument for
Errors in onComplete are also sent to onException, so I think this
mapping is a little off.
> If you want to semi-globally handle all exceptions in Ajax requests,
> as you show you can do it with a responder. If you want to semi-
Sure, after figuring out why exceptions are disappearing, and then
figuring out how to get around that all-encompassing exception block
surrounding the responder. It's a lot of digging to get reasonable
default behavior.
--
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 [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~----------~----~----~----~------~----~------~--~---
Index: static/prototype.js
===================================================================
--- static/prototype.js (revision 1750)
+++ static/prototype.js (working copy)
@@ -1155,6 +1155,7 @@
} catch (e) { }
}
});
+ return this.length > 0;
}
};
@@ -1353,7 +1354,9 @@
dispatchException: function(exception) {
(this.options.onException || Prototype.emptyFunction)(this, exception);
- Ajax.Responders.dispatch('onException', this, exception);
+ var handled = Ajax.Responders.dispatch('onException', this, exception);
+ if(!handled && !this.options.onException)
+ (function() { throw exception; }).defer();
}
});