Well, this is still part the same kind of problem: You are defining an anonymous function in UnitA and trying to call it from UnitB (func.apply). You can see this if you try defining similar anonymous functions in the two units:
// UnitA:
function anonA() { throw new Error("anonA"); }
// UnitB:
function anonB() { throw new Error("anonB"); }
and then call them from main
function main()
{
doSomething(anonB);
doSomething(anonA);
}
Edit:
To finish the thought... the exception handling for anonB() works because the function is defined in UnitB and you're calling it from UnitB. The exception handling for anonA() fails because the function is defined in UnitA and you're calling it from unitB . . . the exception handling crosses unit boundaries.