[Dojo-interest] addOnLoad: exception preventing execution of all remaining functions in the addOnLoad queue

sniii mortenfb at gmail.com
Wed Jun 30 04:49:36 EDT 2010


Heya

A problem that has been bothering me for a while.

I have a lot of page initialization functions being added to
dojo.addOnLoad(...).
However, if one of these functions fails / throws an exception, all the
remaining functions in the addOnLoad queue are simply not executed.

Example:

function initialize() 
{	
	dojo.addOnLoad(a);
	dojo.addOnLoad(b);
	dojo.addOnLoad(c);
}

function a()
{
	alert("a");
}

function b()
{
	var pseudo = null;
	pseudo.focus(); // this will obviously fail with a nullpointer exception
}

function c()
{
	alert("c");
}

In this example, A will be executed correctly, it then proceeds to B which
fails, and C is never executed.
Sure, you could argue that I could catch exceptions in the functions I
supply to addOnLoad, but I'm working in a large organization where I can't
control what everyone else supplies to addOnLoad. Effectively someone could
brick my addOnLoad calls from working by supplying some code that'll blow up
- effectively bricking all the remaining queued addOnLoad functions.

Is there a nice way out of this problematic situation?

A solution could be to run seperate addOnLoad queues / groupings, that would
not affect eachother.
But this seems like a big change to the insides of Dojo...Can anyone come up
with another more lightweight approach to circumvent this problem?

Thanks in advance ;-)
-- 
View this message in context: http://dojo-toolkit.33424.n3.nabble.com/addOnLoad-exception-preventing-execution-of-all-remaining-functions-in-the-addOnLoad-queue-tp932713p932713.html
Sent from the Dojo Toolkit mailing list archive at Nabble.com.


More information about the Dojo-interest mailing list