> I don't think it is the resposibility of the dispatcher to handle
> exceptions.
> I think it it is the resposibility of the dispatcher to dispatch
> events. :-)
> An error in one handler should not prevent another handler from
> executing.
> Nor should a dispatcher suppress errors so that it can complete its
> task.

Why not just use try/finally, then?
Online here, as well:
http://ejohn.org/files/handler.html

<script>
function runHandlers(i){
  i = i || 0;
  try {
    while ( i < handlers.length ) {
      handlers[i]();
      i++;
    }
  } finally {
    if ( i < handlers.length ) {
      runHandlers( i + 1 );
    }
  }
}

var handlers = [
  function(){
    document.write("testA<br>");
    throw "A";
  },
  function(){
    document.write("testB<br>");
  }
];

try {
  runHandlers();
} catch(e){
  document.write("ERROR: " + e + "<br>");
}
</script>

Output:
testA
testB
ERROR: A

I don't think the order of the error is terribly important in this
case. At the very least, though, you get the best of all worlds: All
handlers execute, exceptions are thrown, and performance isn't
sacrificed.

--John

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"jQuery Development" 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/jquery-dev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to